Unverified Commit 01e6f137 authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

nixos/i18n: support "all" for extraLocales (#403567)

parents 972da783 b94a794a
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -6,13 +6,15 @@
}:
let
  aggregatedLocales =
    builtins.map
    (builtins.map
      (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8")
      (
        [ config.i18n.defaultLocale ]
        ++ config.i18n.extraLocales
        ++ (lib.optionals (builtins.isList config.i18n.extraLocales) config.i18n.extraLocales)
        ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
      );
      )
    )
    ++ (lib.optional (builtins.isString config.i18n.extraLocales) config.i18n.extraLocales);
in
{
  ###### interface
@@ -53,13 +55,14 @@ in
      };

      extraLocales = lib.mkOption {
        type = lib.types.listOf lib.types.str;
        type = lib.types.either (lib.types.listOf lib.types.str) (lib.types.enum [ "all" ]);
        default = [ ];
        example = [ "nl_NL.UTF-8" ];
        description = ''
          Additional locales that the system should support, besides the ones
          configured with {option}`i18n.defaultLocale` and
          {option}`i18n.extraLocaleSettings`.
          Set this to `"all"` to install all available locales.
        '';
      };

@@ -108,7 +111,13 @@ in

  config = {
    warnings =
      lib.optional ((lib.subtractLists config.i18n.supportedLocales aggregatedLocales) != [ ])
      lib.optional
        (
          !(
            (lib.subtractLists config.i18n.supportedLocales aggregatedLocales) == [ ]
            || lib.any (x: x == "all") config.i18n.supportedLocales
          )
        )
        ''
          `i18n.supportedLocales` is deprecated in favor of `i18n.extraLocales`,
          and it seems you are using `i18n.supportedLocales` and forgot to