Retrieve languages and translation coverage from server
See original GitHub issueCurrently the available languages are kept on the client-side in frontend/src/app/navbar/languages.ts
in the form
export const languages = [
{ key: 'en', icons: [ 'gb', 'us' ], lang: 'English' },
{ key: 'ar_SA', icons: [ 'ae', 'tn' ], lang: 'عربى' },
{ key: 'az_AZ', icons: [ 'az' ], lang: 'Azərbaycanca', isFlask: true },
{ key: 'bg_BG', icons: [ 'bg' ], lang: 'български (език)' },
...
with the actual language files residing in frontend/src/assets/i18n/*.json
files. This has several issues:
languages.ts
duplicates the actual list of languages itselflanguages.ts
contains the name of the language in that particular language which is a duplicate of theLANGUAGE
key in every/i18n/*.json
file, e.g."LANGUAGE": "عربى"
- The
isFlask: true
flag is manually set based on information from CrowdIn about the translation completeness. As with manual processes, this can easily outdate. Languages with <85% translation ratio should have theisFlask: true
flag
Solution
- Create an API endpoint that delivers the language list based on content of
/i18n/xx_XX.json
files (thexx
is critical to be strictly applied as two letters to avoid spoilering a particular existing challenge!) - Extract the
LANGUAGE
property from each/i18n/xx_XX.json
and add it to the endpoint response to have the label for display in the dropdown - Calculate the translation completeness in percent, e.g. via comparing each
xx_XX.json
withen.json
with https://www.npmjs.com/package/diff - On the server create a mapping for languages to flag icons either programmatically (might not be possible because some languages show multiple flags) or via a simpler version of today’s
languages.ts
- Prepend a static
en
entry with 100% translation completion in every response of the endpoint and have other languages sorted alphabetically
Endpoint /rest/languages
response example
[
{ key: 'en', icons: [ 'gb', 'us' ], lang: 'English', percentage: 100 },
{ key: 'ar_SA', icons: [ 'ae', 'tn' ], lang: 'عربى', percentage: 93 },
{ key: 'az_AZ', icons: [ 'az' ], lang: 'Azərbaycanca', percentage: 40 },
{ key: 'bg_BG', icons: [ 'bg' ], lang: 'български (език)', percentage: 96 },
...
Visualization on UI
Instead of the flask symbol next to incomplete translations the i18n completion could be indicated like this with :
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Retrieve languages and translation coverage from server #854
Create an API endpoint that delivers the language list based on content of /i18n/xx_XX.json files (the xx is critical to be strictly applied...
Read more >The Best Code Coverage Tools By Programming Language
JavaScript. Istanbul: The most famous JS tool for code coverage. Supporting unit tests, server-side functional tests, and browser tests.
Read more >R Can Use Your Help: Translating R Messages - The R Blog
We can see that there are a few languages with near-complete, correct translations: French, Italian, Russian, and Lithuanian. Then there is a ...
Read more >Language Server Extension Guide - Visual Studio Code
Learn how to create Language Servers to provide rich language features in Visual Studio Code.
Read more >Language support | Cloud Translation
Translations from any language to any language in this list are supported. The list is updated as new languages are added. You can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Feel free to work on it, I’ll put it “in progress”. Assigning issues isn’t possible for external users except if you were the ticket creator.
The languages are loaded in the
NavbarComponent
(/frontend/src/app/navbar/navbar.component.ts
) and are presented in a dropdown menu. Currently this list comes from the mentioned static file, in the future it should come from the new API endpoint.