{"_id":"@airtame/translation","name":"@airtame/translation","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@airtame/translation","version":"1.0.3","description":"A library to maintain and update translation in ARC projects.","main":"lib/dist/cjs/index.js","module":"lib/dist/esm/index.js","types":"./lib/dist/esm/index.d.ts","bin":{"translation":"lib/cli.mjs"},"scripts":{"test":"vitest run","build":"npm run clean && npm run build:cjs && npm run build:es","build:cjs":"tsc --project tsconfig.cjs.json","build:es":"tsc --project tsconfig.esm.json","clean":"rimraf ./lib/dist"},"repository":{"type":"git","url":"git@git.svc.airtame.cloud:airtame/arc/translation.git"},"keywords":["i18n","translations"],"engines":{"node":">=16.17.0","npm":">=8.15.0"},"dependencies":{"chalk":"5.2.0","dotenv":"16.0.3","glob":"9.0.1","ts-morph":"17.0.1","typescript":"4.9.4"},"devDependencies":{"@types/node":"^18.11.18","rimraf":"^4.4.0","vitest":"^0.27.2"},"_id":"@airtame/translation@1.0.3","gitHead":"94c5e67e2c9c7be059a3ff0b365807c182f361a1","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-ftk8mFlJ5Mk413Z9vVa6/Q+QksHs7c3znxdJnxm7MMVNDcGEnT2cMjiDsAm1q3EQKxu2rvQG0XLoNkNB/kgiUQ==","shasum":"f3853437113b9131526054ebe1e50116c823a4f3","tarball":"https://registry.npmjs.org/@airtame/translation/-/translation-1.0.3.tgz","fileCount":17,"unpackedSize":21408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB5OXILe+PM3P2F3Q3hxzKiI7dxERI+BLkK7e3xj8VG7AiEAk7o0Sb72T93DrgHSpwxUIF+8LWN2bX6XDqocOq/81l4="}]},"_npmUser":{"name":"airtame-ops","email":"devops@airtame.com"},"directories":{},"maintainers":[{"name":"rene-airtame","email":"rene.hansen@airtame.com"},{"name":"airtame-ops","email":"devops@airtame.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/translation_1.0.3_1711374548124_0.013141046954098679"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-25T13:49:08.027Z","1.0.3":"2024-03-25T13:49:08.276Z","modified":"2024-03-25T13:49:08.871Z"},"maintainers":[{"name":"rene-airtame","email":"rene.hansen@airtame.com"},{"name":"airtame-ops","email":"devops@airtame.com"}],"description":"A library to maintain and update translation in ARC projects.","keywords":["i18n","translations"],"repository":{"type":"git","url":"git@git.svc.airtame.cloud:airtame/arc/translation.git"},"readme":"# Translation\n\nThis package has two purposes:\n1. A CLI tool `translation check|update|placeholders` to check the\n   current translations, run updates on existing translation or to\n   update the placeholders with values from the translation file.\n2. Expose for consumers two function. The first one is\n   `setTranslations(translationObject)` used to populate the\n   translations the package has access to. The second one is the default\n   exported function `t(label, placeholder, parametersObject)` that is\n   meant to match a label to a translation from provided translation\n   object, or populate that translation with the placeholder or label\n   provided by the function caller.\n\nThe exposed function for the consumer will take note of NODE_ENV used\nand for any values other than `production` it will \"highlight\" missing\ntranslation directly into the application. ( It mainly prepends ⚠️\ncharacter to the placeholder strings ).\n\n## Installation\n\n```sh\nnpm install --save-exact @airtame/translation\n```\n\n## CLI\n\n```sh\ntranslations check|update|placeholders\n```\nor\n```sh\ntranslation c|u|p\n```\n\nFollowing environment variables will be used with the CLI command tool:\n- `TRANSLATION_API_KEY` (required) - Auth token value to call\n  localise.biz api with.\n- `TRANSLATION_FILE` (required for `update` command, optional for the others) - the location of\n  the main english translation json file. It defaults to the location of\n  the file in the arc project for `check` and `placeholders` commands.\n- `TRANSLATION_PROJECT_FILES_GLOB` - the glob pattern to target project\n  files where to run the `check` and `placeholders` scripts against. It\n  defaults to `./src/**/*.{ts,tsx}` value.\n- `TRANSLATION_IGNORE_PROJECT_FILES_GLOB` - the glob pattern to ignore\n  files matched by previous mentioned glob\n  (`TRANSLATION_PROJECT_FILES_GLOB`). It defaults to `**/*.stories.tsx` value.\n\n### Check translations:\n\n```sh\ntranslations check|c\n```\n\n### Update translations:\n\n```sh\ntranslations update|u\n```\n\n### Update translations placeholders:\n\n```sh\ntranslations placeholders|p\n```\n\n## Using inside the application:\n\n```typescript\n// \"./src/i18n/i18n.ts\"\n\nimport t, { setTranslations } from \"@airtame/translation\";\nimport en from \"../some/path/to/a/file.json\";\nsetTranslations(en);\nexport default t;\n```\n\n## Development\n\n### Installation\n\n```sh\nnvm install\nnvm use\nnpm ci;\n```\n\n### Test\n\n```sh\nnpm test;\n```\n\n### Build\n\n```sh\nnpm build;\n```\n\n### Testing the project\n---\n#### Testing project exported library/contents:\nFor testing the exported functions in a project, in order to avoid\nhaving to publish new releases for every checked change to the library we can use\n[Yalc](https://www.npmjs.com/package/yalc) to create a local repository.\n\n##### 1. Install yalc\nInstall yalc globally with `npm install -g yalc` so that you can use it from the command line.\n\n##### 2. Publish airtame/translation to yalc\nIn the Airtame UI folder run `npm run build && yalc publish` to publish the library in its current state to the local repository.\n\n##### 3. Install airtame/translation from yalc\nIn your project's folder run `yalc add @airtame/translation` to install translation Package\n\n##### 4. Make changes to translation package\nAfter making changes to the library, update the local repository with `npm run build && yalc push`. The dependency will be automatically updated in the project.\n\n##### 5. Clean up after yourself\nWhen you're done, remove the package with `yalc remove @airtame/translation`. This will remove the local dependency and restore the original from the internal package repository.\n\n---\n\n#### Test the command line tool scripts\nFor testing the command line scripts, Yalc does not support this, so we will have to install it locally.\n\n##### 1. Build and pack by running the following command `npm run build && npm pack`;\n##### 2. Copy the ABSOLUTE path of the newly created `.tgz` file _( For exmaple, the absolute path is `/Users/broscaru/airtame/translation/airtame-translation-0.0.0.tgz`; We copy this to clipboard )_.\n##### 3. In the project you wish to test out the CLI tool, we go in and install the package by providing the absolute path `npm install /Users/broscaru/airtame/translation/airtame-translation-0.0.0.tgz` to the npm install command.\n##### 4. In the project package.json file, under the scripts add an entry: `\"translation\": \"translation\"`\n##### 5. Run the command `npm run translation -- c|u|p` to test the command line scripts.\n---\n\n## Releasing a new version:\n```sh\nnpm version minor\n```\n\n## [CHANGELOG](./CHANGELOG.md)\n","readmeFilename":"README.md"}