|
5 | 5 | ... |
6 | 6 | }: |
7 | 7 | let |
| 8 | + sanitizeUTF8Capitalization = |
| 9 | + lang: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] lang); |
8 | 10 | aggregatedLocales = |
9 | | - (builtins.map |
10 | | - (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") |
11 | | - ( |
12 | | - [ config.i18n.defaultLocale ] |
13 | | - ++ (lib.optionals (builtins.isList config.i18n.extraLocales) config.i18n.extraLocales) |
14 | | - ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings)) |
15 | | - ) |
16 | | - ) |
| 11 | + [ |
| 12 | + "${config.i18n.defaultLocale}/${config.i18n.defaultCharset}" |
| 13 | + ] |
| 14 | + ++ lib.pipe config.i18n.extraLocaleSettings [ |
| 15 | + (lib.mapAttrs (n: v: (sanitizeUTF8Capitalization v))) |
| 16 | + (lib.mapAttrsToList (LCRole: lang: lang + "/" + (config.i18n.localeCharsets.${LCRole} or "UTF-8"))) |
| 17 | + ] |
| 18 | + ++ (builtins.map sanitizeUTF8Capitalization ( |
| 19 | + lib.optionals (builtins.isList config.i18n.extraLocales) config.i18n.extraLocales |
| 20 | + )) |
17 | 21 | ++ (lib.optional (builtins.isString config.i18n.extraLocales) config.i18n.extraLocales); |
18 | 22 | in |
19 | 23 | { |
|
48 | 52 | default = "en_US.UTF-8"; |
49 | 53 | example = "nl_NL.UTF-8"; |
50 | 54 | description = '' |
51 | | - The default locale. It determines the language for program |
52 | | - messages, the format for dates and times, sort order, and so on. |
53 | | - It also determines the character set, such as UTF-8. |
| 55 | + The default locale. It determines the language for program messages, |
| 56 | + the format for dates and times, sort order, and so on. Setting the |
| 57 | + default character set is done via {option}`i18n.defaultCharset`. |
| 58 | + ''; |
| 59 | + }; |
| 60 | + defaultCharset = lib.mkOption { |
| 61 | + type = lib.types.str; |
| 62 | + default = "UTF-8"; |
| 63 | + example = "ISO-8859-8"; |
| 64 | + description = '' |
| 65 | + The default locale character set. |
54 | 66 | ''; |
55 | 67 | }; |
56 | 68 |
|
57 | 69 | extraLocales = lib.mkOption { |
58 | 70 | type = lib.types.either (lib.types.listOf lib.types.str) (lib.types.enum [ "all" ]); |
59 | 71 | default = [ ]; |
60 | | - example = [ "nl_NL.UTF-8" ]; |
| 72 | + example = [ "nl_NL.UTF-8/UTF-8" ]; |
61 | 73 | description = '' |
62 | 74 | Additional locales that the system should support, besides the ones |
63 | 75 | configured with {option}`i18n.defaultLocale` and |
|
74 | 86 | LC_TIME = "de_DE.UTF-8"; |
75 | 87 | }; |
76 | 88 | description = '' |
77 | | - A set of additional system-wide locale settings other than |
78 | | - `LANG` which can be configured with |
79 | | - {option}`i18n.defaultLocale`. |
| 89 | + A set of additional system-wide locale settings other than `LANG` |
| 90 | + which can be configured with {option}`i18n.defaultLocale`. Note that |
| 91 | + the `/UTF-8` suffix used in {option}`i18n.extraLocales` indicates a |
| 92 | + character set, and it must not be added manually here. To use a |
| 93 | + non-`UTF-8` character set such as ISO-XXXX-8, the |
| 94 | + {option}`i18n.localeCharsets` can be used. |
| 95 | + ''; |
| 96 | + }; |
| 97 | + localeCharsets = lib.mkOption { |
| 98 | + type = lib.types.attrsOf lib.types.str; |
| 99 | + default = { }; |
| 100 | + example = { |
| 101 | + LC_MESSAGES = "ISO-8859-15"; |
| 102 | + LC_TIME = "ISO-8859-1"; |
| 103 | + }; |
| 104 | + description = '' |
| 105 | + Per each {option}`i18n.extraLocaleSettings`, choose the character set |
| 106 | + to use for it. Essentially defaults to UTF-8 for all of them. |
80 | 107 | ''; |
81 | 108 | }; |
82 | 109 |
|
|
0 commit comments