-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added option to translate schema titles #199
base: master
Are you sure you want to change the base?
Conversation
Users can now translate schema titles by adding title_processing to their JSONEditor options. Examle: JSONEditor.defaults.options = { templates: 'handlebars', theme: 'bootstrap3', title_processing: function(title){ return I18n(title); } };
👍 IMO, you should also pass the key as a parameter to the processing function : if(this.jsoneditor.options.title_processing) return this.jsoneditor.options.title_processing(title, key); because the key is a safer indication that the title itself. |
@SebT they key is already passed automatically. The current title function uses the key unless a title is defined. |
@jakobrosenberg Yes I know. But your custom function only takes 1 parameter. And inside the scope of your function, we can't know for sure if this parameter is the title or the key. // Let's say the custom function is:
function title_processing(param) {
// here, param can be the key or the title, we don't know
} Because |
Could we have more generic approach to i18n, so that also enum values are translated?
|
Sorry for the late reply. I disagree on your approach. I feel my solution is far more generic and flexible. In only two additional lines it allows for manipulation of the key or title. Anyone is free to use their own i18n library if they want translation; they can capitalize and manipulate the titles or decorate them with tags. It's a simple hook to manipulate the title and it offers more options for a much smaller increase in file size. |
Users can now translate schema titles by adding title_processing to their JSONEditor options.
Examle:
JSONEditor.defaults.options = {
templates: 'handlebars',
theme: 'bootstrap3',
title_processing: function(title){
return I18n(title);
}
};