Discussion: Implementing Reactive i18n for Wizard in Grav 2 Admin-Next #259
Replies: 3 comments
|
Good writeup, and thanks for pushing on this. The premise is half right: Admin-Next's i18n is fully reactive and it does expose a runtime bridge to plugin code, but there was a bug underneath that meant it wouldn't have worked for you even with the right calls. That's now fixed, so the path is clear. The bridge you want is Your The bug underneath.
Fixed in grav-plugin-api on develop: the dictionary now merges a code with its primary subtag, so Two things to do on your side. For the wizard body, in const I18N = () => window.__GRAV_I18N;
function t(key, fallback, params) {
const b = I18N();
if (!b) return fallback;
const full = 'PLUGIN_GIT_SYNC.' + key;
return b.has(full) ? b.t(full, params) : fallback;
}The this._i18nUnsub = I18N()?.subscribe?.(() => this._render());Your For strings that travel through On your branch specifically. The dual-block YAML (flat
You'll need the api plugin from develop to see any of it working. Open a PR whenever you're ready and I'll review it. |
|
Thanks for the detailed guidance. I've implemented your recommendations on the ✅ Implemented:
✅ Verified working:
❌ One remaining issue: The action buttons (Wizard, Synchronize, Reset Local Copy) in the plugin page header don't update when language changes. The issue is in Admin-Next's Question: Should I add a Ready to open a PR when you give the go-ahead. |
|
Proceed with PR. Cheers. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've been working on internationalization (i18n) support for the git-sync wizard and have created a branch:
feat/wizard-i18n-admin2.Current Status
✅ Grav 1.7 + Admin (Classic)
❌ Grav 2 + Admin-Next/Admin2
What's Complete
languages/en.yamlandlanguages/es.yamlmodal-wizard.html.twig,modal-reset.html.twig, etc.admin-next/fields/enc-password.jscomponentWhat's Needed
The Admin-Next implementation requires changes to handle reactive language switching in the SPA:
git-sync.php(onApiFloatingWidgets/onApiPluginPageInfo methods)admin-next/widgets/git-sync.js(translation lookup during runtime)Feel free to check out the
feat/wizard-i18n-admin2branch in my fork to review the currentfoundation work. We could continue investigating and testing solutions there collaboratively to
find the best approach following Grav 2 best practices.
Any guidance on how other plugins handle reactive
Thanks for your time!
All reactions