VolkovLabs / volkovlabs-dynamictext-panel

Business Text Panel for @grafana
https://docs.volkovlabs.io
Apache License 2.0
78 stars 14 forks source link

Add `getLocale()` parameter to JavaScript Code #137

Closed mikhail-vl closed 1 year ago

mikhail-vl commented 1 year ago

Resolves #110

Content:

{{translate "Hello"}}

Default Content:

{{translate "Default"}}
const messages = {
  "Hello": {
    'en': 'Hello',
    'fr': 'Salut',
    'es': 'Hola'
  },
  "Default": {
    'en': "The query didn't return any results.",
    'fr': "La requête n'a renvoyé aucun résultat.",
    'es': "La consulta no arrojó ningún resultado."
  },
}

const locale = getLocale();

handlebars.registerHelper('translate',
  (message) => messages[message][locale] ?? messages[message]['en']);
github-actions[bot] commented 1 year ago

Levitate is-compatible report:

🔍 Resolving @grafana/data@latest... 🔍 Resolving @grafana/ui@latest... 🔍 Resolving @grafana/runtime@latest... 🔍 Resolving @grafana/schema@latest... 🔍 Resolving @grafana/e2e-selectors@latest... 🔍 Resolving @grafana/experimental@latest...

🔬 Checking compatibility between ./src/module.ts and @grafana/data@9.3.2... ✔ Found @grafana/data version 9.3.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/ui@9.3.2... ✔ Found @grafana/ui version 9.3.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/runtime@9.3.2... ✔ Found @grafana/runtime version 9.3.1 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/schema@9.3.2... Skipping package @grafana/schema because it is not used in the project or not installed locally. did you forget to run yarn install or npm install?

🔬 Checking compatibility between ./src/module.ts and @grafana/e2e-selectors@9.3.2... Skipping package @grafana/e2e-selectors because it is not used in the project or not installed locally. did you forget to run yarn install or npm install?

🔬 Checking compatibility between ./src/module.ts and @grafana/experimental@1.0.2... Skipping package @grafana/experimental because it is not used in the project or not installed locally. did you forget to run yarn install or npm install?

✔️ ./src/module.ts appears to be compatible with @grafana/data,@grafana/ui,@grafana/runtime,@grafana/schema,@grafana/e2e-selectors,@grafana/experimental