Ask Your Question
0

Why language code changed by itself?

asked 2016-12-25 18:56:54 -0500

AaronHuang gravatar image

updated 2016-12-25 19:23:02 -0500

Someday I found that I cann't voteup for somebody. Although the upvote sign turned green, but his karma doesn't go up.

In settings.py, I have

LANGUAGE_CODE = 'zh-TW'
LANGUAGES = (('zh-TW', 'Chinese'),)

And I found that in the database, the repute table's language code changed by it self to lowercase after some day.

image description

Does anyone know how to fix this?
Why it set the language_code to 'zh-tw' for my language_code is 'zh-TW'?

edit retag flag offensive close merge delete

Comments

@AaronHuang what was the solution?

Evgeny gravatar imageEvgeny ( 2017-03-02 14:53:09 -0500 )edit

First, I set `LANGUAGE_CODE = 'zh-tw'` and `LANGUAGES = (('zh-tw', 'Chinese'),)` in `settings.py`. And then, I change the existing `zh-TW` language code in the database table (`repute`, `askbot_post`, `askbot_thread`) to `zh-tw`. It seems to solve the problem.

AaronHuang gravatar imageAaronHuang ( 2017-03-02 23:18:14 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-02-24 11:31:50 -0500

This is a strange thing.

But According to Django:

zh_TW is a Locale Name: The language part is always in lower case and the country part in upper case. The separator is an underscore.

zh-tw is a Language Codes: It is generally represented in lower case, but the HTTP Accept-Language header is case-insensitive. The separator is a dash.

It is better to user those codes with all lower case (eg. zh-tw)

more info is available at Official Django Documentation.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-12-25 18:56:54 -0500

Seen: 349 times

Last updated: Feb 24