Coverage for cc_modules/cc_language.py: 100%

1"""

2 camcops_server/cc_modules/cc_language.py

3

4===============================================================================

5

6 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.

7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

8

9 This file is part of CamCOPS.

10

11 CamCOPS is free software: you can redistribute it and/or modify

12 it under the terms of the GNU General Public License as published by

13 the Free Software Foundation, either version 3 of the License, or

14 (at your option) any later version.

15

16 CamCOPS is distributed in the hope that it will be useful,

17 but WITHOUT ANY WARRANTY; without even the implied warranty of

18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

19 GNU General Public License for more details.

20

21 You should have received a copy of the GNU General Public License

22 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.

23

24===============================================================================

25

26**Constants for languages/internationalization.**

27

28 This represents known languages (or, strictly, locales). Compare

29``language.cpp`` on the client.

30

31 At present we don't make this user-configurable and arbitrary (e.g. via an XML

32 file to define languages), largely because it would a little complexity for the

33 user, and because there's not much point in adding a language to the server

34 without adding it for the client, too -- and the client needs recompiling.

35

36 Note that both Python locales (see e.g. ``locale.getlocale()``) and Qt use

37 underscores -- e.g. ``en_GB`` -- so we will too.

38

39"""

40

41# =============================================================================

42# Languages

43# =============================================================================

44

45 DANISH = "da_DK"

46 ENGLISH_UK = "en_GB"

47

48 POSSIBLE_LOCALES_WITH_DESCRIPTIONS = (

49 # Default locale should be first (for auto-selecting <select> HTML).

50 (ENGLISH_UK, "English (UK)"), # DEFAULT LOCALE

51 (DANISH, "Dansk"),

52)

53

54

55# =============================================================================

56# Other constants

57# =============================================================================

58

59 DEFAULT_LOCALE = ENGLISH_UK

60 GETTEXT_DOMAIN = "camcops" # don't alter this

61 POSSIBLE_LOCALES = [_[0] for _ in POSSIBLE_LOCALES_WITH_DESCRIPTIONS]