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

On the fly translations #26

Open
ghost opened this issue Jul 10, 2013 · 5 comments
Open

On the fly translations #26

ghost opened this issue Jul 10, 2013 · 5 comments

Comments

@ghost
Copy link

ghost commented Jul 10, 2013

Hi folks!

This iniatieve is great! I actually don't understand why people don't make their stuff internationalized. Probably in America no multi-language apps are developed...

I don't have an issue with kendo-global but I have a question that you guys hopefully can answer.

I'm using the i18next javascript library to do translations everywhere in my app. I'm also using Angular and created a special directive for the grid component. This means that I've create a custom HTML5 tag with custom attributes and some logic behind it.
That way I can use my tag and the grid already has some defaults and is already translated. So no need to pass it to every new instance over and over again.

Though I have a problem with how the kendo-grid behaves:
Everything is translated: column headers and grid internals (column menu, filtering properties, ...) but only once. So if I switch language in my app, a new resourcebundle is automatically loaded by i18next but the grid isn't re-rendered so translations of previous language are still displayed

So my question: is there a function I can call the re-renders the grid and thus also retrieves the overridden messages again? And if so will that also work for translated column headers (= 'title' property of a column in the 'columns' array you can pass to kendo-grid)?

I guess you guys already sorted this out because on the fly translations wiill be something that is (or needs to be) supported by your framework...

Thanks in advance!

Kind regards,
Glenn

@loudenvier
Copy link
Owner

We're working on it! We're adding another "translation format" which is actually a JSON object + a function to apply the new translation. We'll keep the static translation for those that only need a single language.

Take a look at this: #19 (comment)

You can also visit his repository where there is already a version of kendo-global working with the "on the fly" translation... You can grab it from there, and translate what you need to the new format... Then make a pull request!

I'm still experimenting with it to find the best way to publish this functionality.

@ghost
Copy link
Author

ghost commented Jul 10, 2013

Nice! I'll grab the code!

If you implement JSON objects for translations, consider using i18next: http://i18next.com/
I've used it on the previous project and chose it immediately on the current one because it's a really great i18n library. It supports a lot (plurals, inheritance, object retrieval, named parameters, caching, ...), has HTML5 support (data-i18n attribute automatically does translations) and is easy to configure (though it has a lot of things you can configure if you really want)...

@ghost
Copy link
Author

ghost commented Jul 29, 2013

Do you guys know how te completely refresh a grid along with it's headers and buttons?
I can manage to reload the data by calling $("#grid").data("kendoGrid").refresh(). Content will be re-evaluated and thus re-translated in current language but this is not working for kendo grid's translations like button labels and so on...

Also, I would like to reload all grid's on my page and not only that one that has #grid as id... I'm not a big jquery expert so I don't know how I can execute something like that. $(".grid").data("kendoGrid").refresh() doesn't seem to work...

@loudenvier
Copy link
Owner

Hi,

You may try to use the "each" jQuery function that will pass each matched object to a function, and in this function you can call the needed methods to refresh the grid. I never tried that with Kendo grid, but it seems that "each" will suffice: http://api.jquery.com/each/

@loudenvier
Copy link
Owner

There's an update in this issue! See #52 ... User marklagendijk did an amazing job and converted everything to JSON files... His changes will make it possible to load translations on the fly and will also autogenerate the static files JavaScript from the JSON data so that we can only work on the JSON and the .js versions will be generated without duplication of code (my English is, for some unknown reason, very cryptic today :-) )

The problem is that he uses node.js and some other "things" I never used on my life (I'm mostly an embedded and .NET developer) so I'm a little slow catching up (which will only cause trouble for me because I'll have to create JSON files for the many translations that came after his pull request)

But now I'm committed again to kendo-global!!! It's a promise!

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

No branches or pull requests

1 participant