{"id":19312408,"url":"https://github.com/offen/l10nify","last_synced_at":"2025-07-16T23:32:26.823Z","repository":{"id":43070212,"uuid":"280377351","full_name":"offen/l10nify","owner":"offen","description":"gettext based localization workflow for Javascript / Browserify","archived":false,"fork":false,"pushed_at":"2024-02-24T20:08:42.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-22T02:53:05.247Z","etag":null,"topics":["browserify","browserify-transform","gettext","i18n","javascript","localization","xgettext"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/offen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-17T09:00:15.000Z","updated_at":"2022-09-05T23:24:15.000Z","dependencies_parsed_at":"2024-11-10T00:34:50.136Z","dependency_job_id":"82c63581-cf52-4e69-a912-b6f5ff94e2d7","html_url":"https://github.com/offen/l10nify","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"27640475fb5baf471ec3ea91032490a5b9a01821"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/offen/l10nify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offen%2Fl10nify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offen%2Fl10nify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offen%2Fl10nify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offen%2Fl10nify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/offen","download_url":"https://codeload.github.com/offen/l10nify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offen%2Fl10nify/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265550349,"owners_count":23786547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browserify","browserify-transform","gettext","i18n","javascript","localization","xgettext"],"created_at":"2024-11-10T00:34:42.689Z","updated_at":"2025-07-16T23:32:26.808Z","avatar_url":"https://github.com/offen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.offen.software/\"\u003e\n  \u003cimg src=\"https://offen.github.io/press-kit/avatars/avatar-OS-header.svg\" alt=\"offen.software logo\" title=\"offen.software\" width=\"60px\"/\u003e\n\u003c/a\u003e\n\n# l10nify\n\nLocalization workflow for Browserify\n\n## How does this work?\n\nThis is a Browserify-based workflow for localizing client side applications. It is built for use cases where you can and want to ship one bundle per locale. Strings are defined by calling a pseudo-global function (i.e. `__(string, args..)`) in the default language in your code (similar to GNU gettext or similar). Strings are stored in `.po` files.\n\n## Installation\n\nInstall from npm:\n\n```\nnpm install @offen/l10nify\n```\n\nThis installs two things:\n\n- a Browserify transform for localizing strings at bundle time. It is references as `@offen/l10nify`\n- a `extract-strings` command that you can use to generate PO files from your JavaScript code.\n\n## Usage\n\n### Defining strings in client side code\n\nIn your code, use the `__(string, args...)` function (`__` is the default, but you can use anything) to declare strings in your default language (which defaults to `en` but can be anything you want it to):\n\n```js\nconst HappyBirthdayComponent = (props) =\u003e {\n  return (\n    \u003ch1\u003e{__('Happy birthday, %s!', props.name)}\u003c/h1\u003e\n  )\n}\n```\n\n### Extract strings from your code\n\nNext, you can extract these strings from your code into `.po` files using the `extract-strings` command:\n\n```\n$(npm bin)/extract-strings **/*.js\n```\n\nThis will extract the strings from all matching files and print a `.po` file to stdout. Use the standard `gettext` tools like `msgmerge` and `msgcat` to combine the output with existing `.po` files.\n\nRefer to `extract-strings --help` for a full list of options\n\n#### Why not just use `xgettext`\n\nWhile `xgettext` works perfectly fine on ES5 code, it will choke on ES6+ syntax and also does not support parsing JSX, which `l10nify` supports.\n\n### Apply the transform at bundle time\n\nApply the transform to your Browserify setup passing the target `locale`. In development, you can omit this parameter to make the transform return the default locale, i.e. the strings you defined in code.\n\n```js\nvar browserify = require('browserify')\n\nvar b = browserify()\nb.add('app.js')\nb.transform('@offen/l10nify', { locale: 'fr' })\nb.bundle(function (err, src) {\n  // consume bundle\n})\n```\n\n#### Options\n\nThe following options can be passed to the transform:\n\n##### `locale`\n\n`locale` specifies the locale which you want to return when bundling. It defaults to `en` or `process.env.LOCALE` when set.\n\n##### `defaultLocale`\n\n`defaultLocale` specifies the default locale that is used to define strings in code. It defaults to `en` or `process.env.DEFAULT_LOCALE` when set.\n\n##### `source`\n\n`source` specifies the directory in which the `\u003cLOCALE\u003e.po` files are stored. It defaults to `./locales` or `process.env.SOURCE` when set.\n\n##### `global`\n\n`global` defines the global function identifier that is used for defining strings in code. It defaults to `__` or `process.env.GLOBAL` when set.\n\n## License\n\nCopyright 2020 Frederik Ring - `l10nify` is available under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffen%2Fl10nify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foffen%2Fl10nify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foffen%2Fl10nify/lists"}