From 8b43df95f266c0dbed388d5f6f1e5a732f8eef81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Fri, 19 Jan 2024 23:02:26 +0100 Subject: [PATCH] Add documentation about extension localization --- .github/CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++++ README.md | 2 +- docs/docs/index.md | 3 ++- docs/docs/user-guide/extension.md | 10 ++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 438d42b9..74761b5c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -96,6 +96,39 @@ WebExtensions message format, with a few differences: * Referencing other messages is possible, include a placeholder to another key in the placeholder content. * Limited pluralization is possible, supporting a very basic subset of the ICU message pluralization format. +The pluralization support is based on a very basic subset of the ICU message +pluralization syntax, with the following limitations: + +* Supports only the pluralization type (`plural`). +* Supports only one variable key. +* Does not support nested messages. +* Only supports `#` placeholder inside messages. + +As Crowdin is compatible with this format, you mostly don't need to worry about +these changes if you are translating through Crowdin. More details about special +features can be found [in a Crowdin discussion](https://crowdin.com/project/firefoxpwa/discussions/2). + +
+ Notes for developers + +The localization messages are stored in a WebExtensions-compatible format. +When creating a new message, please make sure that it follows the same +message ID style as other messages and contains an appropriate description. + +When creating an HTML element that needs to be translated, add a `data-i18n` +attribute with its content set to the message ID. If you need to translate +specific attributes, you can set `data-i18n-ATTRIBUTE-NAME` to the message +ID. Even if the element only uses attribute translations, it still needs +a `data-i18n` attribute, but it can be empty. + +For accessing translated messages through JS, the `getMessage` function +from the `i18n` file can be used. + +For accessing messages from the background script, use the standard +`browser.i18n.getMessage` function instead. In this case, make sure +to add the uses message IDs to the `messages` list in `package.json`. +
+ ### UserChrome Translations It is currently not possible to translate the UserChrome messages, but support diff --git a/README.md b/README.md index 38bb2824..2d6902c2 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Thanks to [all contributors](https://github.com/filips123/PWAsForFirefox/graphs/ ### Other Mentions -Thanks to [all package maintainers](https://repology.org/project/firefoxpwa/information) making sure the project is up-to-date! Thanks to [all stargazers](https://github.com/filips123/PWAsForFirefox/stargazers) who starred our repository on GitHub. Finally, thanks to Mozilla and its developers for creating Firefox and making it possible to modify its UI using JavaScript! +Thanks to [all package maintainers](https://repology.org/project/firefoxpwa/information) making sure the project is up-to-date! Thanks to [all translators](https://crowdin.com/project/firefoxpwa) making the project available in multiple languages! Thanks to [all stargazers](https://github.com/filips123/PWAsForFirefox/stargazers) who starred our repository on GitHub. Finally, thanks to Mozilla and its developers for creating Firefox and making it possible to modify its UI using JavaScript! ## Versioning diff --git a/docs/docs/index.md b/docs/docs/index.md index 5008b2ee..312b8400 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -115,7 +115,8 @@ to this project for providing help and developing features!

Other Mentions

Thanks to [all package maintainers](https://repology.org/project/firefoxpwa/information) -making sure the project is up-to-date! Thanks to [all stargazers](https://github.com/filips123/PWAsForFirefox/stargazers) +making sure the project is up-to-date! Thanks to [all translators](https://crowdin.com/project/firefoxpwa) +making the project available in multiple languages! Thanks to [all stargazers](https://github.com/filips123/PWAsForFirefox/stargazers) who starred our repository on GitHub. Finally, thanks to Mozilla and its developers for creating Firefox and making it possible to modify its UI using JavaScript! diff --git a/docs/docs/user-guide/extension.md b/docs/docs/user-guide/extension.md index a4b125eb..cdbe806b 100644 --- a/docs/docs/user-guide/extension.md +++ b/docs/docs/user-guide/extension.md @@ -171,6 +171,16 @@ when a website has own "redirection" URLs that you do not want to open in a web This option only has an effect when [automatic web app launching](#enable-automatic-web-app-launching) is enabled. +### Language + +The extension is translated into multiple languages. You can select which one you want to use. + +!!! warning + + Translations are maintained by the community and may be incomplete or incorrect. + + You can help to improve them on [Crowdin](https://crowdin.com/project/firefoxpwa). + ### Update web apps This will download and parse manifests for all your web apps and register them again to