Coverage for /builds/kinetik161/ase/ase/gui/i18n.py: 100.00%

8 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

1# i18n = i(18 letters omitted)n = internationalization 

2"""Module for l10n (localization) with gettext. 

3 

4When this module is imported, ASE-GUI will use translations depending 

5on system settings. Usually language is taken from the LANG or LANGUAGE 

6environment variables. Examples of how to override the system locale: 

7 

8 LANG=da_DK.UTF-8 ase gui (Danish) 

9 LANGUAGE=da_DK.UTF-8 ase gui (Danish; normally overrides LANG) 

10 LANG=C ase gui (bare-bones ASCII locale disabling translations) 

11 

12Other languages: es_ES.UTF-8, en_UK.UTF-8, ... 

13 

14The encoding and/or country code can be omitted on most systems/languages. 

15 

16Translations will be loaded from the mo-files when possible. See ase/gui/po. 

17 

18All modules that need translations should import _ from here, 

19along with ngettext if they want to translate messages with plurals 

20(e.g. "Save 1 file", "Save %d files").""" 

21 

22import gettext 

23import os 

24 

25domain = 'ag' 

26localedir = f'{os.path.dirname(__file__)}/po/' 

27translation = gettext.translation(domain, localedir, fallback=True) 

28 

29 

30_ = translation.gettext 

31ngettext = translation.ngettext