question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retrieve languages and translation coverage from server

See original GitHub issue

Currently 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:

  1. languages.ts duplicates the actual list of languages itself
  2. languages.ts contains the name of the language in that particular language which is a duplicate of the LANGUAGE key in every /i18n/*.json file, e.g. "LANGUAGE": "عربى"
  3. 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 the isFlask: true flag

Solution

  • 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 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 with en.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 :

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bkimminichcommented, Mar 29, 2019

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.

1reaction
bkimminichcommented, Mar 28, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found