mbi / django-rosetta

Rosetta is a Django application that eases the translation process of your Django projects
MIT License
1.07k stars 195 forks source link

Chinese locale directory should be named 'zh_Hans' instead of 'zh_hans' #282

Closed sunfkny closed 11 months ago

sunfkny commented 11 months ago

Django won't discover 'zh_hans' https://github.com/django/django/blob/b287af5dc954628d4b336aefc5027b2edceee64b/django/utils/translation/__init__.py#L230-L243 so rosetta fallback to the default language. After renaming the directory to 'zh_Hans', the chinese translation works

sunfkny commented 11 months ago

My temporary workaround

import rosetta
import pathlib

rosetta_path = pathlib.Path(list(rosetta.__path__)[0])
rosetta_zh_hans_source_path = rosetta_path / "zh_hans"
rosetta_zh_hans_dest_path = rosetta_path / "zh_Hans"
if rosetta_zh_hans_source_path.exists():
    rosetta_zh_hans_source_path.rename(rosetta_zh_hans_dest_path)
mbi commented 11 months ago

Good catch, thank you!