Skip to content

Add localization for Simplified Chinese

Cédric Bellegarde requested to merge ksqsf:selection-l10n into master

Created by: ksqsf

This is an unfinished effort to address issue #1226 (closed) .

I introduced a locale package, submodule of which should export a function named latinized_index. It's later imported in 'utils'. This is how it works (zh_CN):

latinized_index('你好') # 'N', because the pronunciation is 'ni hao'
latinized_index('再见') # 'Z', because the pronunciation is 'zai jian'
latinized_index('1abc') # '#', because the first char is a digit
latinized_index('もも') # '…', because Japanese Hiragana is not recognizable in Chinese locale
latinized_index('Zoo') # 'Z', obviously

I changed one line (not in this pull request),

-        to_add = noaccents(c.upper())
+        to_add = latinized_index(noaccents(c.upper()))

and now the fast scroll looks good, except that '…' should be put after 'A'~'Z', and it doesn't work either. fast scroll

The selection list is expected to work like this. Android Contacts (Photo taken from my Android phone)

To achieve this effect, I introduced 'categorize()' in utils.py:

categorize(['赵', 'Zoo', '马', 'Moo', '别', 'Boo', 'ももこ'])
# => {'…': ['ももこ'], 'B': ['Boo', '别'], 'M': ['Moo', '马'], 'Z': ['Zoo', '赵']}

Since the order of English and Chinese is not so important, here I simply use 'strxfrm' to sort strings in each group, which will put English before Chinese, but group '#' and group '…' should be put after 'A', ... 'Z'.

Last thing is to make selection works. I'm not familiar with GTK+. I guess we need a trasition from ListModel to TreeModel?

Merge request reports