Skip to content

Commit

Permalink
home-manager: support i18n of install script
Browse files Browse the repository at this point in the history
  • Loading branch information
rycee committed Dec 14, 2021
1 parent c1677de commit 3d9eb1c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 27 deletions.
49 changes: 24 additions & 25 deletions home-manager/install.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
{ home-manager, runCommand }:
{ home-manager, gettext, runCommand, ncurses }:

runCommand "home-manager-install" {
propagatedBuildInputs = [ home-manager ];
let

hmBashLibInit = ''
export TEXTDOMAIN=home-manager
export TEXTDOMAINDIR=${home-manager}/share/locale
source ${home-manager}/share/bash/home-manager.sh
'';

in runCommand "home-manager-install" {
propagatedBuildInputs = [ home-manager gettext ncurses ];
preferLocalBuild = true;
shellHookOnly = true;
shellHook = ''
${hmBashLibInit}
confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix"
if [[ ! -e $confFile ]]; then
echo
echo "Creating initial Home Manager configuration..."
_i "Creating initial Home Manager configuration..."
nl=$'\n'
xdgVars=""
Expand Down Expand Up @@ -53,34 +63,23 @@ runCommand "home-manager-install" {
fi
echo
echo "Creating initial Home Manager generation..."
_i "Creating initial Home Manager generation..."
echo
if home-manager switch; then
cat <<EOF
All done! The home-manager tool should now be installed and you
can edit
$confFile
to configure Home Manager. Run 'man home-configuration.nix' to
see all available options.
EOF
if home-manager switch ; then
# translators: The "%s" specifier will be replaced by a file path.
_i $'All done! The home-manager tool should now be installed and you can edit\n\n %s\n\nto configure Home Manager. Run \'man home-configuration.nix\' to\nsee all available options.' \
"$confFile"
exit 0
else
cat <<EOF
Uh oh, the installation failed! Please create an issue at
https://github.com/nix-community/home-manager/issues
if the error seems to be the fault of Home Manager.
EOF
# translators: The "%s" specifier will be replaced by a URL.
_i $'Uh oh, the installation failed! Please create an issue at\n\n %s\n\nif the error seems to be the fault of Home Manager.' \
"https://github.com/nix-community/home-manager/issues"
exit 1
fi
'';
} ''
echo This derivation is not buildable, instead run it using nix-shell.
${hmBashLibInit}
_iError 'This derivation is not buildable, please run it using nix-shell.'
exit 1
''
35 changes: 34 additions & 1 deletion home-manager/po/home-manager.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Home Manager\n"
"Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n"
"POT-Creation-Date: 2021-12-13 00:45+0100\n"
"POT-Creation-Date: 2021-12-14 18:53+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -132,3 +132,36 @@ msgstr ""
#: home-manager/home-manager:702
msgid "Unknown command: %s"
msgstr ""

#: home-manager/install.nix:22
msgid "Creating initial Home Manager configuration..."
msgstr ""

#: home-manager/install.nix:66
msgid "Creating initial Home Manager generation..."
msgstr ""

#. translators: The "%s" specifier will be replaced by a file path.
#: home-manager/install.nix:71
msgid ""
"All done! The home-manager tool should now be installed and you can edit\n"
"\n"
" %s\n"
"\n"
"to configure Home Manager. Run 'man home-configuration.nix' to\n"
"see all available options."
msgstr ""

#. translators: The "%s" specifier will be replaced by a URL.
#: home-manager/install.nix:76
msgid ""
"Uh oh, the installation failed! Please create an issue at\n"
"\n"
" %s\n"
"\n"
"if the error seems to be the fault of Home Manager."
msgstr ""

#: home-manager/install.nix:83
msgid "This derivation is not buildable, please run it using nix-shell."
msgstr ""
3 changes: 2 additions & 1 deletion xgettext
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ function run() {
-k_ipError:1,2 --flag=_ip:1:c-format --flag=_ip:2:c-format \
-k_ipWarn:1,2 --flag=_ip:1:c-format --flag=_ip:2:c-format \
-k_ipNote:1,2 --flag=_ip:1:c-format --flag=_ip:2:c-format \
--add-comments=translators: \
-o "$output" -d "$domain" "$@"
}

run 'Home Manager' \
home-manager/po/home-manager.pot \
home-manager \
home-manager/home-manager
home-manager/home-manager home-manager/**/*.nix

run 'Home Manager Modules' \
modules/po/hm-modules.pot \
Expand Down

0 comments on commit 3d9eb1c

Please sign in to comment.