{"_id":"@crisgfx/kirbyup-plugin-i18n-updater","name":"@crisgfx/kirbyup-plugin-i18n-updater","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@crisgfx/kirbyup-plugin-i18n-updater","version":"1.0.0","description":"For kirby panel plugin devs: See instant updates of Your locale files edits.","author":{"name":"Cris","url":"@crisgfx"},"license":"MIT","type":"module","exports":{".":"./i18nUpdater.js","./updateLocale":"./updateLocale.js"},"repository":{"url":"git+https://github.com/crisgfx/kirbyup-plugin-i18n-updater.git"},"keywords":["kirby","kirbyup","kirbyup-plugin","plugin","i18n","language","translation","panel"],"gitHead":"096ad3ea8dda0e472cf2642cd9b3e084b0350c3e","_id":"@crisgfx/kirbyup-plugin-i18n-updater@1.0.0","bugs":{"url":"https://github.com/crisgfx/kirbyup-plugin-i18n-updater/issues"},"homepage":"https://github.com/crisgfx/kirbyup-plugin-i18n-updater#readme","_nodeVersion":"25.1.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-cCu/Nny0kVt7r3xxzIwGUfcxi/8i19XnO1b3wBidt/ivMJKL80hm03NvY5TJOPybyMrtyyCpDGJ6142kLj34Hw==","shasum":"e17aa344a15e875b8fa4746a69f3c9b3ae0a409f","tarball":"https://registry.npmjs.org/@crisgfx/kirbyup-plugin-i18n-updater/-/kirbyup-plugin-i18n-updater-1.0.0.tgz","fileCount":6,"unpackedSize":5893,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCxJQ6HWzvRdJwWJRjWKCn7yi6UPHOZanfWAsfzVbOAuwIgKds/Z+e7+l63QWhsw562NwSKRWCaxVC2l3W9Y6vLiX4="}]},"_npmUser":{"name":"crisgfx","email":"other@cgaccounts.net"},"directories":{},"maintainers":[{"name":"crisgfx","email":"other@cgaccounts.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kirbyup-plugin-i18n-updater_1.0.0_1765210280253_0.3986383682596655"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-08T16:11:20.140Z","1.0.0":"2025-12-08T16:11:20.402Z","modified":"2025-12-08T16:11:20.714Z"},"maintainers":[{"name":"crisgfx","email":"other@cgaccounts.net"}],"description":"For kirby panel plugin devs: See instant updates of Your locale files edits.","homepage":"https://github.com/crisgfx/kirbyup-plugin-i18n-updater#readme","keywords":["kirby","kirbyup","kirbyup-plugin","plugin","i18n","language","translation","panel"],"repository":{"url":"git+https://github.com/crisgfx/kirbyup-plugin-i18n-updater.git"},"author":{"name":"Cris","url":"@crisgfx"},"bugs":{"url":"https://github.com/crisgfx/kirbyup-plugin-i18n-updater/issues"},"license":"MIT","readme":"# i18nUpdater for kirbyup\n\nA very basic Vite / [kirbyup](https://kirbyup.getkirby.com/) plugin for panel plugin devs (😱 Pluginception) to instantly show changes in the current view, whenever You edit Your plugin's locale files.  \n\n## Installation\n\n```bash\nnpm i -D @crisgfx/kirbyup-i18nUpdater\n```\n\n## Usage\n\nRegister the plugin in Your `kirbyup` config file.  \nAdd a `source` path to the folder that contains all language files (they must be `.json` files, i.e. `en.json`, `de.json`, etc...).\n\n```js\n// `kirbyup.config.js`\nimport i18nUpdater from '@crisgfx/kirbyup-i18n-updater'\n\nexport default defineConfig({\n  vite: {\n    // ...\n    plugins: [\n      i18nUpdater({\n        source: 'src/i18n/'\n      })\n    ],\n    // ...\n  }\n});\n```\n\nThen, in Your plugin's main entry point add the callback, that takes care of refreshing the current panel view:\n\n```js\n// `index.js`\nimport { updateLocale } from '@crisgfx/kirbyup-i18n-updater/updateLocale'\n\n// Listen for locale file changes in dev mode.\nif (import.meta.env.DEV && import.meta.hot) {\n  import.meta.hot.on('i18n-update', updateLocale)\n}\n\npanel.plugin(\"florian-silberrücken/kirby-monkeyboy\", {\n  // Plugin magic.\n});\n```\n\n> [!TIP]  \n> You probably already know how to do this, but I wanted to use Github's fancy [alerts](https://docs.github.com/de/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) – so, here's a quick and dirty example on how to load `json` files into Your translations array – though it might be better to write the code a bit more readable and outsource it to a dedicated file, in order to keep Your plugin structure clean and tidy.\n\n```php\n<?php\n// index.php\nuse Kirby\\Cms\\App;\nuse Kirby\\Filesystem\\Dir;\nuse Kirby\\Toolkit\\A;\nuse Kirby\\Data\\Json;\n\n$sourceDir = __DIR__ . '/src/i18n';\n\nApp::plugin(\n  'florian-silberrücken/kirby-monkeyboy',\n  extends: [\n    // ...\n    'translations' => array_merge(\n\t\t\t...A::map(Dir::files($sourceDir),\n\t\t\tfunction ($file) use($sourceDir) {\n\t\t\t\tif ($translations = Json::read($sourceDir . '/' . $file)) {\n\t\t\t\t\t// Store translations in corresponding locale array.\n\t\t\t\t\treturn [basename($file, '.json') => $translations];\n\t\t\t\t} \n\t\t\t})\n\t\t)\n  ]\n);\n```\n\n---\n\n## NOTES\n\nThanks to @johannschopplich and @jonaskuske for creating [kirbyup](https://kirbyup.getkirby.com/)! ❤︎\n\n## License\n\n[MIT](./LICENSE) © 2025 [Cris](https://cris.graphics)","readmeFilename":"README.md","_rev":"1-ce183adc62a8b5f694ab22273504c95c"}