diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index fc1859c41..b5885ed41 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -257,9 +257,8 @@ It also means that some features are not supported, such as message context and We also expect all files to be UTF-8-encoded. In practice, this should not matter much for contributing translations. -Translation sources are -stored in the ``po`` directory, named ``ll_CC.po``, where ``ll`` is the -two (or possibly three) letter ISO 639-1 language code of the target language +Translation sources are stored in the ``localization/po`` directory and named ``ll_CC.po``, +where ``ll`` is the two (or possibly three) letter ISO 639-1 language code of the target language (e.g. ``pt`` for Portuguese). ``CC`` is an ISO 3166 country/territory code, (e.g. ``BR`` for Brazil). An example for a valid name is ``pt_BR.po``, indicating Brazilian Portuguese. @@ -273,7 +272,7 @@ More specifically, you will need ``msguniq`` and ``msgmerge`` for creating trans language. To create a new translation, run:: - build_tools/update_translations.fish po/ll_CC.po + build_tools/update_translations.fish localization/po/ll_CC.po This will create a new PO file containing all messages available for translation. If the file already exists, it will be updated. @@ -319,7 +318,7 @@ Editing PO files Many tools are available for editing translation files, including command-line and graphical user interface programs. For simple use, you can use your text editor. -Open up the PO file, for example ``po/sv.po``, and you'll see something like:: +Open up the PO file, for example ``localization/po/sv.po``, and you'll see something like:: msgid "%s: No suitable job\n" msgstr "" @@ -347,7 +346,7 @@ Modifications to strings in source files If a string changes in the sources, the old translations will no longer work. They will be preserved in the PO files, but commented-out (starting with ``#~``). If you add/remove/change a translatable strings in a source file, -run ``build_tools/update_translations.fish`` to propagate this to all translation files (``po/*.po``). +run ``build_tools/update_translations.fish`` to propagate this to all translation files (``localization/po/*.po``). This is only relevant for developers modifying the source files of fish or fish scripts. Setting Code Up For Translations diff --git a/build_tools/update_translations.fish b/build_tools/update_translations.fish index 5de7f5c36..d1bbc1ae7 100755 --- a/build_tools/update_translations.fish +++ b/build_tools/update_translations.fish @@ -9,9 +9,10 @@ # For developers: # - Run with no args to update all PO files after making changes to Rust/fish sources. # For translators: -# - Specify the language you want to work on as an argument, which must be a file in the po/ -# directory. You can specify a language which does not have translations yet by specifying the -# name of a file which does not yet exist. Make sure to follow the naming convention. +# - Specify the language you want to work on as an argument, which must be a file in the +# localization/po/ directory. You can specify a language which does not have translations +# yet by specifying the name of a file which does not yet exist. +# Make sure to follow the naming convention. # For testing: # - Specify `--dry-run` to see if any updates to the PO files would by applied by this script. # If this flag is specified, the script will exit with an error if there are outstanding @@ -31,7 +32,7 @@ set -gx LC_ALL C.UTF-8 set -l build_tools (status dirname) -set -l po_dir $build_tools/../po +set -l po_dir $build_tools/../localization/po set -l extract @@ -89,8 +90,9 @@ if set -l --query extract end if set -l --query _flag_dry_run - # On a dry run, we do not modify po/ but write to a temporary directory instead and check if - # there is a difference between po/ and the tmpdir after re-generating the PO files. + # On a dry run, we do not modify localization/po/ but write to a temporary directory instead + # and check if there is a difference between localization/po/ and the tmpdir after re-generating + # the PO files. set -g tmpdir (mktemp -d) # Ensure tmpdir has the same initial state as the po dir. @@ -146,7 +148,7 @@ end if set -g --query tmpdir[1] diff -ur $po_dir $tmpdir or begin - echo ERROR: translations in ./po/ are stale. Try running build_tools/update_translations.fish + echo ERROR: translations in localization/po/ are stale. Try running build_tools/update_translations.fish cleanup_exit end end diff --git a/crates/gettext-maps/build.rs b/crates/gettext-maps/build.rs index 4d1b5c473..6e326cd80 100644 --- a/crates/gettext-maps/build.rs +++ b/crates/gettext-maps/build.rs @@ -11,7 +11,11 @@ fn main() { PathBuf::from(fish_build_helper::fish_build_dir()).join("fish-localization-map-cache"); embed_localizations(&cache_dir); - fish_build_helper::rebuild_if_path_changed(fish_build_helper::workspace_root().join("po")); + fish_build_helper::rebuild_if_path_changed( + fish_build_helper::workspace_root() + .join("localization") + .join("po"), + ); } fn embed_localizations(cache_dir: &Path) { @@ -21,7 +25,9 @@ fn embed_localizations(cache_dir: &Path) { io::{BufWriter, Write}, }; - let po_dir = fish_build_helper::workspace_root().join("po"); + let po_dir = fish_build_helper::workspace_root() + .join("localization") + .join("po"); // Ensure that the directory is created, because clippy cannot compile the code if the // directory does not exist. @@ -41,7 +47,7 @@ fn embed_localizations(cache_dir: &Path) { "Could not find msgfmt required to build message catalogs. \ Localization will not work. \ If you install gettext now, you need to trigger a rebuild to include localization support. \ - For example by running `touch po` followed by the build command." + For example by running `touch localization/po` followed by the build command." ); } Err(e) => { diff --git a/po/de.po b/localization/po/de.po similarity index 100% rename from po/de.po rename to localization/po/de.po diff --git a/po/en.po b/localization/po/en.po similarity index 100% rename from po/en.po rename to localization/po/en.po diff --git a/po/fr.po b/localization/po/fr.po similarity index 100% rename from po/fr.po rename to localization/po/fr.po diff --git a/po/pl.po b/localization/po/pl.po similarity index 100% rename from po/pl.po rename to localization/po/pl.po diff --git a/po/pt_BR.po b/localization/po/pt_BR.po similarity index 100% rename from po/pt_BR.po rename to localization/po/pt_BR.po diff --git a/po/sv.po b/localization/po/sv.po similarity index 100% rename from po/sv.po rename to localization/po/sv.po diff --git a/po/zh_CN.po b/localization/po/zh_CN.po similarity index 100% rename from po/zh_CN.po rename to localization/po/zh_CN.po diff --git a/po/zh_TW.po b/localization/po/zh_TW.po similarity index 100% rename from po/zh_TW.po rename to localization/po/zh_TW.po diff --git a/tests/checks/po-files-well-formed.fish b/tests/checks/po-files-well-formed.fish index b253f7e10..bfe4676d7 100644 --- a/tests/checks/po-files-well-formed.fish +++ b/tests/checks/po-files-well-formed.fish @@ -4,7 +4,7 @@ set -l dir (status dirname) set -l fail_count 0 -for file in $dir/../../po/*.po +for file in $dir/../../localization/po/*.po # We only check the format strings. # Later on we might do a full "--check" to also check the headers. msgfmt --check-format $file