Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

internationalization doesn't work in my velocity template


Hi, Community,

in my Jira plugin, I have created a servlet module that renders a Velocity file.

the problem is that internationalization doesn't work only in this file which is rendered by servlet, however, it works the rest of velocity files created by other modules.

when I have for example:

<h1>$i18n.getText("key. Title")</h1>

it renders ' $i18n.getText("key.title") ' in the interface.

I added my velocity file in atlassian.plugin.xml like that:

<web-resource name="gedSearcher" i18n-name-key="" key="ged-searcher">
<description key="ged-searcher.description">The gedSearcher Plugin</description>
<resource name="ged searcher" type="velocity" location="templates/GEDSearcher.vm"/>

but it still doesn't work, could anyone help me please to solve this problem!

1 answer

1 accepted

0 votes
Answer accepted

Hi @IMENE FIRAS can you share the code of your servlet class? How do you render velocity template?

hi @Martin Bayer [MoroSystems, s.r.o.]  ,

here is my servelt's code, and i'm renedering the file GEDSearcher.vm that can't be internationalized

public class GedSearcher extends HttpServlet {

private static final Logger log = LoggerFactory.getLogger(GedSearcher.class);
VelocityTemplatingEngine vte = ComponentAccessor.getComponent(VelocityTemplatingEngine.class);

protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {



Hi @IMENE FIRAS I think the problem is you do not provide i18n service/component in the context. Most of the modules like Action, Webpanel are already prepared and i18n is injected so it can be used easily.

With Servlet, you need to inject for example I18nResolver (com.atlassian.sal.api.message.I18nResolver) to your servlet and you need to provide in a context (Map) when rendering file.

//pseudo code only
map = ["i18n", I18nResolver]

Let me know if you need more help :) 

Like IMENE FIRAS likes this

Hello @Martin Bayer [MoroSystems, s.r.o.] ,

thanks for your useful answer, it allowed me to solve my problem and actually everything works well :D

Good job @IMENE FIRAS :) and thank you for accepting the answer :)

@Martin Bayer [MoroSystems, s.r.o.] , in fact iam still having a problem,


As u told me i have injected the i18nresolver in my servlet:

private final I18nResolver i18n = ComponentAccessor.getOSGiComponentInstanceOfType(I18nResolver.class);


When i use the method 'getText' like this  : 


it works well and brings the internitionalized  text.


But when i have tried to render all the internitionalized text in my velocity template by using map like this :

Map<String,String> map = i18n.getAllTranslationsForPrefix("prefix_key");

Map<String,Object> mapObj= new HashMap<>(map);


it didn't work, and it's still rendring ' $i18n.getText("my_key") ' in the interface.

Hi @IMENE FIRAS , I probably didn't describe it precisely. You need to give i18n  to the context, so you can use $i18n variable in your template. It should be something like:

Map<String,Object> context= new HashMap<>;
context.put("i18n", i18n)

Now you should be able to use $i18n variable in your velocity template GEDSearcher.vm

Like imene.firas likes this

@Martin Bayer [MoroSystems, s.r.o.]  it's finally working !! thank you very much Mr.Bayen

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events