I am new to UI world and currently working on Localization. I was able to translate the texts which are in HTML files but came up in a situation where Controller returns a list of values which is being displayed in views looping through it. I am stuck how am I proceed to solve this:
Sample code:
part of view.html:
<div ng-repeat="section in vm.sections" class="apiconfig-container">
<div class="apiconfig-list-wrapper m-b-30">
<div class="page-title-wrapper">
<h3>{{section.title}}</h3>
</div>
<table class="table table-list">
<tr ng-repeat="link in section.links">
<td><a href="{{link.href}}">{{link.name}}</a></td>
<td></td>
</tr>
</table>
</div>
</div>
Part of Controller:
this.sections.push(this.getLinks());
getLinks() {
const baseUrl = `${this.baseUrl}/config/#`;
let array = [];
if (!this.someCheck("some_condition")) {
array.push({
name: "test1",
href: `${baseUrl}/test1`
});
array.push({
name: "test2",
href: `${baseUrl}/test2`
});
}
return { title: "Configurations", links: array };
}
This is just sample incomplete code. Basically, Controller is returning name: "test1" name: "test2" which I want to be a variable that should picked up from the locale file, how do I achieve that. Or is there any other better approach?