Skip to content

Comments

feat: add i18n support (Phase 1)#1589

Merged
g3john merged 11 commits intomainfrom
feat/add-i18n-support
Feb 23, 2026
Merged

feat: add i18n support (Phase 1)#1589
g3john merged 11 commits intomainfrom
feat/add-i18n-support

Conversation

@g3john
Copy link
Contributor

@g3john g3john commented Feb 11, 2026

What this PR does / why we need it

We want to add i18n support to the SM plugin. This PR sets up i18n for contribution, and adds some translations as a proof of concept

Screenshot 2026-02-11 at 4 00 52 PM

Which issue(s) this PR fixes

Implements Phase 1 of #1556

@github-actions github-actions bot added the feature A feature added to the application. label Feb 11, 2026
@@ -1,4 +1,4 @@
{
"version": "6.7.8",
"version": "6.8.4",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto updated when running npx @grafana/create-plugin@latest update

@@ -75,4 +75,152 @@ We use the file nesting feature to help manage the growing number of files in th
}
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best place to put this documentation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good location for it.
Just a heads up that the developer-facing stuff here is solid and will stick around (how to use t()/Trans, key naming, best practices). But the workflow sections (extraction, adding languages, file structure) will probably need a rewrite once we get Crowdin set up in Phase 2.

@g3john g3john changed the title feat: add i18n support feat: add i18n support (Phase 1) Feb 11, 2026
@g3john g3john requested a review from VikaCep February 11, 2026 21:27
@g3john g3john marked this pull request as ready for review February 11, 2026 21:27
@g3john g3john requested review from a team as code owners February 11, 2026 21:27
@g3john g3john marked this pull request as draft February 11, 2026 21:40
Copy link
Contributor

@VikaCep VikaCep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻 YAY! Love this work.

A few comments on the translations.

I see this branches off chore/migrate-react-router-v6 as you mentioned. I think that's good as we should merge it soon. But I'm wondering if that is purely because @grafana/i18n with initPluginTranslations requires the Grafana 12.2+ packages that come with that upgrade, or is there a direct dependency I'm missing?

@@ -0,0 +1,41 @@
{
"addNewCheckButton": {
"createNewCheck": "Crear nuevo cheque"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"createNewCheck": "Crear nuevo cheque"
"createNewCheck": "Crear nueva prueba"

I think "prueba" sounds more natural than "chequeo".
Cheque on the other hand refers to the one from the bank 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also how it's set in the breadcrumbs

Image

"checkFilters": {
"alerts": "Alertas",
"all": "Todos",
"allProbes": "Todas las sondas",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"allProbes": "Todas las sondas",
"allProbes": "Todos los agentes",

I'd use "agentes" directly. Otherwise "ubicaciones" could work as well.

"filterByAlertsAriaLabel": "Filtrar por alertas",
"filterByStatusAriaLabel": "Filtrar por estado",
"filterByTypeAriaLabel": "Filtrar por tipo",
"probes": "Sondas",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"probes": "Sondas",
"probes": "Agentes",

"filterByStatusAriaLabel": "Filtrar por estado",
"filterByTypeAriaLabel": "Filtrar por tipo",
"probes": "Sondas",
"searchChecksAriaLabel": "Buscar chequeos",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"searchChecksAriaLabel": "Buscar chequeos",
"searchChecksAriaLabel": "Buscar pruebas",

"filterByTypeAriaLabel": "Filtrar por tipo",
"probes": "Sondas",
"searchChecksAriaLabel": "Buscar chequeos",
"searchPlaceholder": "Buscar por nombre de trabajo, punto final o etiqueta",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"searchPlaceholder": "Buscar por nombre de trabajo, punto final o etiqueta",
"searchPlaceholder": "Buscar por nombre del job, endpoint o etiqueta",

I'd keep the technical terms as they are, since they don't translate well.

"selectAllAriaLabel": "Seleccionar todos",
"setThresholds": "Establecer umbrales",
"sortOptions": {
"ascExecutions": "Ejecuciones asc. ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"ascExecutions": "Ejecuciones asc. ",
"ascExecutions": "Ejecuciones asc.",

"setThresholds": "Establecer umbrales",
"sortOptions": {
"ascExecutions": "Ejecuciones asc. ",
"ascReachability": "Accesibilidad asc. ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"ascReachability": "Accesibilidad asc. ",
"ascReachability": "Accesibilidad asc.",

"sortOptions": {
"ascExecutions": "Ejecuciones asc. ",
"ascReachability": "Accesibilidad asc. ",
"descExecutions": "Ejecuciones desc. ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"descExecutions": "Ejecuciones desc. ",
"descExecutions": "Ejecuciones desc.",

"ascExecutions": "Ejecuciones asc. ",
"ascReachability": "Accesibilidad asc. ",
"descExecutions": "Ejecuciones desc. ",
"descReachability": "Accesibilidad desc. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"descReachability": "Accesibilidad desc. "
"descReachability": "Accesibilidad desc."

src/module.tsx Outdated

import { ProvisioningJsonData } from './types';

await initPluginTranslations(pluginJson.id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having it in module.tsx produces a a +281.38% increase according to Danger.js.
The bundle size increase is because it imports whole package to the main bundle that Grafana loads upfront.
We could avoid this by initialising translations inside the lazy() loaders instead, so it loads alongside the app code on demand rather than upfront.

Copy link
Contributor

@ckbedwell ckbedwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! What's the plan for when we say this PR is ready to go in?

I just looked at the parent issue and I think a missing piece is updating our CI/CD workflow to integrate this. At the moment it seems easy to add a new translation key but forget to run the i18n extract script. Do we have plans to address that?

Base automatically changed from chore/migrate-react-router-v6 to main February 13, 2026 17:12
@g3john g3john force-pushed the feat/add-i18n-support branch from 1959d39 to e561d6b Compare February 13, 2026 19:48
@github-actions
Copy link

github-actions bot commented Feb 13, 2026

Fails
🚫

module.js has exceeded the Critical threshold of a 10% size increase in this PR.

Script size changes

Name +/- Main This PR Outcome
[942.js] -0.80% 2,134.82 kB 2,117.65 kB
[854.js] New file - 802.30 kB
[datasource/module.js] = 25.25 kB 25.25 kB
[692.js] = 20.64 kB 20.64 kB
[503.js] New file - 17.46 kB
[663.js] = 5.83 kB 5.83 kB
[module.js] +14.98% 4.59 kB 5.28 kB 🚨
[156.js] = 1.90 kB 1.90 kB
[361.js] Deleted file 801.28 kB -

Totals

Name +/- Main This PR Outcome
[Scripts] +0.07% 2,994.31 kB 2,996.29 kB
[Non-script Assets] +0.10% 2,680.09 kB 2,682.76 kB
[All] +0.08% 5,674.39 kB 5,679.05 kB

Generated by 🚫 dangerJS against 8945144

@g3john
Copy link
Contributor Author

g3john commented Feb 18, 2026

Looking good! What's the plan for when we say this PR is ready to go in?

I just looked at the parent issue and I think a missing piece is updating our CI/CD workflow to integrate this. At the moment it seems easy to add a new translation key but forget to run the i18n extract script. Do we have plans to address that?

@ckbedwell
Good call! At first thought I figure it was fine since it won't break anything if they did forget to run the script, but contributors working on adding translations wouldn't even know the string exists if they weren't extracted.

Added a workflow to the CI to validate, and fails if they forgot to extract

@g3john g3john marked this pull request as ready for review February 18, 2026 19:35
@g3john g3john force-pushed the feat/add-i18n-support branch from 3a9888a to 44a4b84 Compare February 18, 2026 19:37
@g3john
Copy link
Contributor Author

g3john commented Feb 18, 2026

😻 YAY! Love this work.

A few comments on the translations.

I see this branches off chore/migrate-react-router-v6 as you mentioned. I think that's good as we should merge it soon. But I'm wondering if that is purely because @grafana/i18n with initPluginTranslations requires the Grafana 12.2+ packages that come with that upgrade, or is there a direct dependency I'm missing?

@VikaCep
It was mostly because running npx @grafana/create-plugin@latest made a lot of the same updates as the upgrade PR, so instead of conflicting with it I just branched off of it

@g3john
Copy link
Contributor Author

g3john commented Feb 18, 2026

Confirmed that the new verification works!
Screenshot 2026-02-18 at 2 46 22 PM

@g3john g3john requested review from VikaCep and ckbedwell February 18, 2026 19:51
VikaCep
VikaCep previously approved these changes Feb 19, 2026
Copy link
Contributor

@VikaCep VikaCep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 👏 👏 t('pr.approved', 'Great work!')

ckbedwell
ckbedwell previously approved these changes Feb 20, 2026
Copy link
Contributor

@ckbedwell ckbedwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Teeny tiny nit. I'm approving anyway so take that as feel free to merge when you are ready.

I have wanted this for AGES so I am super chuffed that you got on top of it so swiftly. Great job! 👏 ❤️

value={isAllSelected}
disabled={checks.length === 0}
aria-label="Select all"
aria-label={t('checkList.header.selectAllAriaLabel', 'Select all')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this matches what is on line 82 we should use the same key. We should document that we will default to brevity for shared strings and then if they need to be split up at a later date we will add it.

I know the Grafana team had a conversation about how to handle shared strings which are repeatedly used throughout their codebase but I don't know what conclusions they arrived at and what their key naming conventions for those are. Could be worth looking up?

Not for this PR (if ever... juice / squeeze matrix ) but I wonder if there is a solution where for common strings we can use Grafana's translation files rather than us duplicating them, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I couldn't find anything on slack or google docs relating to this, so I started a thread

Copy link
Contributor Author

@g3john g3john Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the sentiment is to use separate keys, since the two “Select all” strings have different use cases — one is tooltip content and the other is an aria-label

Another argument we could make is that the same word in English can have different meanings, and may need different translations depending on context and location

With that in mind, if we were to put common strings in a centralized translation file though, we’d need to be explicit about the context and intended use for each string

VikaCep and others added 7 commits February 20, 2026 11:55
- Upgrade react-router-dom from v5 to v6.27.0
- Remove react-router-dom-v5-compat dependency
- Update React to 18.3.0 and Grafana packages to 12.2.0
- Migrate route imports and navigation to v6 APIs
- Use locationService for programmatic navigation
- Update webpack externals configuration
Initialize @grafana/i18n before rendering scenes components.
Workaround for grafana/scenes#1322
@g3john g3john dismissed stale reviews from ckbedwell and VikaCep via 8945144 February 20, 2026 16:58
@g3john g3john force-pushed the feat/add-i18n-support branch from a07917e to 8945144 Compare February 20, 2026 16:58
@g3john
Copy link
Contributor Author

g3john commented Feb 20, 2026

@VikaCep @ckbedwell had to re-request your reviews for rebasing 😅
Did the way I rebase cause this or does it always invalidate approvals when a new commit goes on

@g3john g3john requested review from VikaCep and ckbedwell February 20, 2026 17:00
@g3john g3john enabled auto-merge (squash) February 20, 2026 22:35
Copy link
Contributor

@VikaCep VikaCep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 💯

@g3john g3john merged commit 75be46d into main Feb 23, 2026
37 of 38 checks passed
@g3john g3john deleted the feat/add-i18n-support branch February 23, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A feature added to the application.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants