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

nixos/i18n: handle C locale better (#460010)

parents c5a6500f 26813ab5
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -7,13 +7,16 @@
let
  sanitizeUTF8Capitalization =
    lang: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] lang);
  aggregatedLocales = [
  aggregatedLocales =
    lib.optionals (config.i18n.defaultLocale != "C") [
      "${config.i18n.defaultLocale}/${config.i18n.defaultCharset}"
    ]
    ++ lib.pipe config.i18n.extraLocaleSettings [
      # See description of extraLocaleSettings for why is this ignored here.
      (x: lib.removeAttrs x [ "LANGUAGE" ])
      (lib.mapAttrs (n: v: (sanitizeUTF8Capitalization v)))
      # C locales are always installed
      (lib.filterAttrs (n: v: v != "C"))
      (lib.mapAttrsToList (LCRole: lang: lang + "/" + (config.i18n.localeCharsets.${LCRole} or "UTF-8")))
    ]
    ++ (map sanitizeUTF8Capitalization (
@@ -111,6 +114,9 @@ in
        description = ''
          Per each {option}`i18n.extraLocaleSettings`, choose the character set
          to use for it. Essentially defaults to UTF-8 for all of them.

          Note that for a locale category that uses the `C` locale, setting a
          character set to it via this setting is ignored.
        '';
      };

+27 −1
Original line number Diff line number Diff line
@@ -38,6 +38,32 @@
        };
      };
    };
    Csimple = {
      i18n = {
        defaultLocale = "C";
      };
    };
    CnonDefault = {
      i18n = {
        defaultLocale = "en_US.UTF-8";
        extraLocaleSettings = {
          LC_COLLATE = "C";
          LC_MESSAGES = "C";
          LC_TIME = "C";
        };
      };
    };
  testScript = { nodes, ... }: "";
  };
  testScript =
    { nodes, ... }:
    lib.pipe nodes [
      builtins.attrNames
      (map (node: ''
        ${node}.copy_from_vm(
            ${node}.succeed("readlink -f /etc/locale.conf").strip(),
            "${node}"
        )
      ''))
      (lib.concatStringsSep "\n")
    ];
}