Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilanguage support in templates ? #308

Closed
emu42 opened this issue Apr 7, 2017 · 3 comments
Closed

Multilanguage support in templates ? #308

emu42 opened this issue Apr 7, 2017 · 3 comments
Labels

Comments

@emu42
Copy link

emu42 commented Apr 7, 2017

Hello,

is there a way to internationalize a mosaico template? I mean labels and such like "Show Title" in the versafix template. I am aware of multilanguage support in the menus (by passing the respective resources to Mosaico on initialization), but without i18n support in templates this seems like an incomplete solution.

Or is the only way to currently achieve this, by copying and translating the template for each language?

Regards,
Edmund

@bago
Copy link
Member

bago commented Apr 7, 2017

At this time we think the best way is to provide translated templates. Given strings are defined in templates you can't expect them to be part of a "language pack for the library".

BTW, if you want to make mosaico try to translate those strings like the UI strings then you can create a viewModel plugin like this:

templateLanguagePlugin = function(viewModel) {
  viewModel.ut = function(category, key) {
    return viewModel.tt(key);
  };
};

viewModel.ut function is called for most template labels.

@bago bago closed this as completed Apr 7, 2017
@bago bago added the question label Apr 7, 2017
@emu42
Copy link
Author

emu42 commented Apr 10, 2017

Hello Bago,

I tried this solution, but so far it's not working. Eg. I added "Image position": "Bild Position" to mosaico-de.json, but the label still shows as "Image position".

I did some debugging and it seems the viewModel.tt(key) call always returns the original key. The plugin is registered and it does get called. Also, I double-checked the initialization parameters and the "Image position" key definitely gets passed to Mosaico along with the other German language resources (which show up just fine in the menus etc.). I have not (as yet) debugged the viewModel.tt(..) method and I hope you can spare me the trouble. ;)

@emu42
Copy link
Author

emu42 commented Apr 10, 2017

Ah, nevermind. I just figured out that I need to call viewModel.t(..) instead of .tt(..).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants