
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
gettext-utils
Advanced tools
A set of utils to parse react files and export .po files and import them back
A set of utils to extract strings from JS application to .pot file, merge it with existing .po files and / import these strings back to a react-targem or lioness compatible .json file / validate that all the strings are translated before release
npm i --save-dev gettext-utils
export-strings [input-files-glob] [output] [--default-locale=locale] [--po-files-path]
parse through all the files provided in input-files-glob
(src/**/{*.js,*.jsx,*.ts,*.tsx}
by default) (uses glob) and generate .pot file in the output path (./src/i18n/template.pot
by default). Then searches for all the .po
files in the same directory and updates them with new strings to translate. If default-locale
is provided (e.g. en
) and this locale's .po
file exists in the same folder (e.g. en.po
), this file will be populated with the translations automatically. You can specify additional path(s) to update .po
files by using --po-files-path your/custom/folder your/other/directory
.import-strings [po-files-path] [output] [--optimize=true] [--split-by-locale=false]
parse all the .po
files inside the directory provided as po-files-path
(./src/i18n/
by default) and generate react-targem or lioness compatible .json
file in the output path (./src/i18n/translations.json
), which is an object with each locale as a key and gettext-parser object for this locale as a value. By default all translations.json
are optimized, e.g. all unnecessary fields are removed. Pass --no-optimize
or --optimize=false
to disabled optimizations. You can also pass --split-by-locale
option to write translations for different locales into separate files.merge-translations [po-files-dir-path] [template-path]
merge updated .pot file with .po. Done automatically by export-strings
command. If default-locale
is provided (e.g. en
) and this locale's .po
file exists in the same folder (e.g. en.po
), this file will be populated with the translations automatically.validate-strings [po-files-dir-path] [template-path]
validate all .po
files inside po-files-dir-path
(./src/i18n/
by default) to have all the translations in the .pot
file provided in template-path
(./src/i18n/template.pot
by default).For example, you have a react project in src
folder and you want to use react-targem or lioness to translate your application.
npm i --save react-targem
or npm i --save lioness
npm i --save-dev gettext-utils
<T>
component or withTranslations
HOC.npx gettext-utils export-strings
to create a src/i18n/template.pot
file.prestart
and prebuild
scripts inside scripts
section of your package.json
: "prestart": "gettext-utils import-strings"
to generate translations.json
file automatically./src/i18n/translations.json
file inside your .gitignore
(this file is generated automatically).gettext-utils export-strings --default-locale=en && git add src/i18n/*
in any precommit hook you are using, so the translations will be exported automatically (husky).develop
branch before relase.npx gettext-utils validate-strings
to make sure that everything is translated before each release.FAQs
A set of utils to parse react files and export .po files and import them back
The npm package gettext-utils receives a total of 475 weekly downloads. As such, gettext-utils popularity was classified as not popular.
We found that gettext-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.