Skip to content

Can't select Chinese locale in appearance page #2562

@hustcc

Description

@hustcc

Hello, sentry is very nice. But I maybe find a bug.
I have locale file In src/sentry/locale, but can not find Simplified Chinese option in appearance page. Exactly, can not find the option which locale name contains -. Look at below:

issue_image

Search the code, I find code in conf/server.py

from .locale import CATALOGS
LANGUAGES = tuple((code, name) for code, name in LANGUAGES
                  if code in CATALOGS)

the problem is at code in CATALOGS. code is standard locale code, but CATALOGS is a dir name list, can not match. e.g. zh_TW != zh-tw.

So need to updae code in conf/locale.py, below:

#change locale file dir name to locale code
def dirname_to_local(dir_name):
    if '_' in dir_name:
        pre, post = dir_name.split('_', 1)
        dir_name = '{}-{}'.format(pre, post.lower())
    return dir_name

with open(os.path.join(os.path.dirname(sentry.__file__),
                       'locale', 'catalogs.json'), 'r') as f:
    CATALOGS = json.load(f)['supported_locales']
    CATALOGS = [dirname_to_local(dirname) for dirname in CATALOGS]

If this solution is OK, can I push a request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions