문제

I am an advanced user of Dojo and now implementing i18n. As part of it - I need the ability to have resource file with arguments - something like this:

root: {
  personalHello: 'Hello {1}'
}

So, when I call it with a name it will be something like this:

somDiv.innerHTML = i18n.personalHello['David']

Or something like this. Can anyone refer me to an example that uses it?

Thanks!

도움이 되었습니까?

해결책

OK, found the answer in this link.

Appearently, you can do something like this in resources:

root: {
  personalHello: 'Hello ${a1}'
}

And then call it like this from the code:

somDiv.innerHTML = dojo.string.substitute(i18n.personalHello, {a1: 'David'};

In Dojo >= 1.7 (AMD):

require(["dojo/string"], function(string) {
  somDiv.innerHTML = string.substitute(i18n.personalHello, {a1: 'David'};
})

Checked it. It works!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top