Today I had a small issue to imple­ment a trans­la­tion for an i18n call, via this post I want you to show the issue and how to resolve it.

It has to do that you can spec­ify a ‘com­ment’ in your i18n call to give the trans­la­tors more context.

This was the i18n con­tent I wanted to trans­late. This is located in the ratings-component.

i18n.get("I love it", "Rating meaning for 5 stars")

My think­ing was that a sling:key with the value of ‘I love it’ should be enough.

Well it is not, because of the com­ment that is spec­i­fied (Rat­ing mean­ing for 5 stars).

When you have a com­ment, the i18n-api expects the fol­low­ing sling:key “I love it ((Rat­ing mean­ing for 5 stars))”

Below an exam­ple with a nice Dutch translation.

Related docs

i18n Javadoc

Happy cod­ing.

@heervisscher