Localization Custom Task
Dear colleagues!
How to localize the title of custom tasks?
If I use this code: app.custom.formTasks.add('mouse request to the service', location.NewcomerInformation, function (formObj, ViewModel) {...)} an error occurs: "SCRIPT5009:' localization ' is undefined
File: custom.js line: 45, column: 1"
Thank you!
Comments
To localize the name of the task, you must put the code inside of a document.ready() call. For example:
$(document).ready(function () {
app.custom.formTasks.add('Incident', localization.LocalizationKey, function (formObj, viewModel) {
// code goes here
});
});
Thanks,
Nick
Great! It works! Thanks!!!
Now I have a problem with a localization of html template (task form).
The lable on the button: <%= localization.OK %>
Tell me the solution, please.
This is when the html template is loaded into your code. The cont variable is essentially a really long string at this point, and we have access to all the methods available for any other string. Your localizations can now be done by inserting the following snippet for each phrase you want to localize:
In your HTML file itself, only the key would be specified. When the template is read in, it would be replaced based on the key using the code above. Does that make sense?
Thank you very much! It works for me! It's very simple!
cont.html(function(i, cont) {
cont = cont.replace("localization.Cancel",localization.Cancel);
cont = cont.replace("localization.OK",localization.OK);
cont = cont.replace("localization.ContractStartDate",localization.ContractStartDate);
cont = cont.replace("localization.ContractEndDate",localization.ContractEndDate);
cont = cont.replace("localization.Location",localization.Location);
cont = cont.replace("localization.Department",localization.Department);
cont = cont.replace("localization.Position",localization.Position);
cont = cont.replace("localization.Position",localization.Position);
cont = cont.replace("localization.LastName",localization.LastName);
cont = cont.replace("localization.LastName",localization.LastName);
cont = cont.replace("localization.FirstName",localization.FirstName);
cont = cont.replace("localization.FirstName",localization.FirstName);
cont = cont.replace("localization.PatronymicName",localization.PatronymicName);
cont = cont.replace("localization.PatronymicName",localization.PatronymicName);
cont = cont.replace("localization.MonthOfBirth",localization.MonthOfBirth);
cont = cont.replace("localization.DayOfBirth",localization.DayOfBirth);
cont = cont.replace("localization.Room",localization.Room);
cont = cont.replace("localization.EnterContractDate",localization.EnterContractDate);
return cont;
});