doc: improved plugins' translation
Massimo Melina committed
Apr 11, 2024 at 09:58 UTC
81c917ee4be5ee3c16027aa5504e9193295cb1bd
1 file changed
+5
-4
dev-plugins.md
+5
-4
@@ -383,16 +383,17 @@ Where `h` is just `import { createElement as h } from 'react'`.
383
384
## Internationalization (i18n)
385
386
-To make your plugin multi-language you can use `HFS.t` function in javascript, like this: `HFS.t("Hello!")`.
386
+To make your plugin multi-language you can use `HFS.t` function in javascript, like this: `HFS.t('myPlugin_greeting', "Hello!")`.
387
Now, to add translations, you'll add files like `hfs-lang-XX.json` to your plugin (same folder as plugin.js),
388
where XX is the language code. The system is basically the same used to translate the rest of HFS,
389
and you can [read details here](https://github.com/rejetto/hfs/wiki/Translation).
390
391
-In the previous example "Hello!" is used both as key for translation and as for default text.
392
-If you want to separate these 2 things, just pass 2 parameters, key and default text. Eg: `HFS.t('greeting', "Hello!")`.
391
+In the previous example `myPlugin_greeting` is the name of the translation, while `Hello!` is the default text.
392
+Instead of `myPlugin` use some text that you feel unique and no one else will use, to be sure that the same name
393
+is not used by another plugin, or even HFS in the future.
394
395
If you need to pass variables in the text, introduce a third parameter in the middle.
395
-Eg: `HFS.t('filter_count', {n:filteredVariable}, "{n} filtered")`
396
+Eg: `HFS.t('myPlugin_filter_count', {n:filteredVariable}, "{n} filtered")`
397
398
## API version history
399