English 中文(简体)
Can t 获得Django当地就业
原标题:Can t get Django localization to work

我搜索了几处read子和ug子报告,但没有找到解决办法。

我将我的Django项目地点改为pt-br,但未作任何改动。 除所有投入领域和产出外,其他投入领域和产出将日期和数目本地化,特别是<代码>DECIMAL_SEPARATOR和THOUSAND_SEPARATOR,包括行政标本。 但是,继续以<代码>yyy-mm-ddd和 decimal Divor“”为标题,在投入时会产生错误。

我所发现的一切都:改变了环境,增加了地方化中层意识课程,使美国E_I18N和USE_L10N能够手工地强迫当地化等。 这里是我环境的 gl光。 py:

LANGUAGE_CODE =  pt-br 
USE_I18N = True
USE_L10N = True

MIDDLEWARE_CLASSES = (
     django.middleware.common.CommonMiddleware ,
     django.middleware.locale.LocaleMiddleware ,
     django.contrib.sessions.middleware.SessionMiddleware ,
     django.contrib.auth.middleware.AuthenticationMiddleware ,
     django.middleware.transaction.TransactionMiddleware ,
)

DATE_FORMAT =  d/m/Y 
SHORT_DATE_FORMAT =  d/m/Y 
DATE_INPUT_FORMATS = ( %d/%m/%Y ,  %d/%m/%y ,  %Y-%m-%d )
DECIMAL_SEPARATOR =  , 
THOUSAND_SEPARATOR =  . 

我的沙尔·奥列尔是否用巴西的葡萄牙视窗产出了吗?

>>> locale.setlocale(locale.LC_ALL, ( pt_BR ,  cp1252 ))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:Python25liblocale.py", line 478, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

我所想尝试的任何想法?

最佳回答

视窗使用不同的当地身份识别器。 The following should work (obtained from the table on Microsoft ssite):

In [15]: locale.setlocale(locale.LC_ALL,  Portuguese_Brazil )
Out[15]:  Portuguese_Brazil.1252 
问题回答

根据,Django Line,INPUT_FORMATS,如果将USE_L10N 定在/code>上,则不予考虑。

也许是一个比喻,但我想在网上翻译上补充我的看法。

我强烈建议使用Bablic。 它采取完全由客户方参与的翻译方法。 他们跟踪你现场展示的画面,建立“字典”,并通知你新的或未经翻译的文本。 它们也可以与云层翻译供应商合并,以便即使新提交的内容也几乎立即翻译,而无需跟踪或更新服务器边代码或配置。

我爱心的是,你并不需要做整个集束手——和;先发式文件到翻译——和;多功能和多功能;研发;德布格-得特;复读。 作为网络发展者,这一解决办法在我结束的时候是零的。

在某些情况下,服务器无法使用,你需要管理这一指挥系统,使当地人能够使用(如我的服务器Utub)。

sudo locale-gen pt_BR

接着,

python -c "import locale; locale.setlocale(locale.LC_ALL,  pt_BR )"




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签