Coverage for cc_modules/cc_language.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-11-08 23:14 +0000

1#!/usr/bin/env python 

2 

3""" 

4camcops_server/cc_modules/cc_language.py 

5 

6=============================================================================== 

7 

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

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

10 

11 This file is part of CamCOPS. 

12 

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

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

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

16 (at your option) any later version. 

17 

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

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

20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

21 GNU General Public License for more details. 

22 

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

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

25 

26=============================================================================== 

27 

28**Constants for languages/internationalization.** 

29 

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

31``language.cpp`` on the client. 

32 

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

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

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

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

37 

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

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

40 

41""" 

42 

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

44# Languages 

45# ============================================================================= 

46 

47DANISH = "da_DK" 

48ENGLISH_UK = "en_GB" 

49 

50POSSIBLE_LOCALES_WITH_DESCRIPTIONS = ( 

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

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

53 (DANISH, "Dansk"), 

54) 

55 

56 

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

58# Other constants 

59# ============================================================================= 

60 

61DEFAULT_LOCALE = ENGLISH_UK 

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

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