How to extend unavailable Locale.Language by default in action controller?












0















So I am trying to implement a Struts 1 I18N application with some languages that are not supported by default (Swedish, Portuguese, Spanish etc.) But when I define Locale.Portuguese in action controller for example, it would shows me PORTUGUESE cannot be resolved or is not a field. Why? How can I extends it so that I can proceed with it? Can someone explains it how is it relatable?



public ActionForward french(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
session.setAttribute("org.apache.struts.action.LOCALE", Locale.FRENCH);
return mapping.findForward(SUCCESS);
}









share|improve this question

























  • Just out of curiosity: is this a new application? If so why are you using a framework that's been dead for about 10 years?

    – Thomas
    Nov 26 '18 at 8:52











  • @Thomas Ikr. But I have to. Because there is an application based on Struts 1 was implemented & used for many years (and still) by my company. I am instructed to implement I18N for it.

    – Boosted Nub
    Nov 26 '18 at 8:56
















0















So I am trying to implement a Struts 1 I18N application with some languages that are not supported by default (Swedish, Portuguese, Spanish etc.) But when I define Locale.Portuguese in action controller for example, it would shows me PORTUGUESE cannot be resolved or is not a field. Why? How can I extends it so that I can proceed with it? Can someone explains it how is it relatable?



public ActionForward french(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
session.setAttribute("org.apache.struts.action.LOCALE", Locale.FRENCH);
return mapping.findForward(SUCCESS);
}









share|improve this question

























  • Just out of curiosity: is this a new application? If so why are you using a framework that's been dead for about 10 years?

    – Thomas
    Nov 26 '18 at 8:52











  • @Thomas Ikr. But I have to. Because there is an application based on Struts 1 was implemented & used for many years (and still) by my company. I am instructed to implement I18N for it.

    – Boosted Nub
    Nov 26 '18 at 8:56














0












0








0








So I am trying to implement a Struts 1 I18N application with some languages that are not supported by default (Swedish, Portuguese, Spanish etc.) But when I define Locale.Portuguese in action controller for example, it would shows me PORTUGUESE cannot be resolved or is not a field. Why? How can I extends it so that I can proceed with it? Can someone explains it how is it relatable?



public ActionForward french(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
session.setAttribute("org.apache.struts.action.LOCALE", Locale.FRENCH);
return mapping.findForward(SUCCESS);
}









share|improve this question
















So I am trying to implement a Struts 1 I18N application with some languages that are not supported by default (Swedish, Portuguese, Spanish etc.) But when I define Locale.Portuguese in action controller for example, it would shows me PORTUGUESE cannot be resolved or is not a field. Why? How can I extends it so that I can proceed with it? Can someone explains it how is it relatable?



public ActionForward french(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession();
session.setAttribute("org.apache.struts.action.LOCALE", Locale.FRENCH);
return mapping.findForward(SUCCESS);
}






java locale struts struts-1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 8:57







Boosted Nub

















asked Nov 26 '18 at 8:47









Boosted NubBoosted Nub

22013




22013













  • Just out of curiosity: is this a new application? If so why are you using a framework that's been dead for about 10 years?

    – Thomas
    Nov 26 '18 at 8:52











  • @Thomas Ikr. But I have to. Because there is an application based on Struts 1 was implemented & used for many years (and still) by my company. I am instructed to implement I18N for it.

    – Boosted Nub
    Nov 26 '18 at 8:56



















  • Just out of curiosity: is this a new application? If so why are you using a framework that's been dead for about 10 years?

    – Thomas
    Nov 26 '18 at 8:52











  • @Thomas Ikr. But I have to. Because there is an application based on Struts 1 was implemented & used for many years (and still) by my company. I am instructed to implement I18N for it.

    – Boosted Nub
    Nov 26 '18 at 8:56

















Just out of curiosity: is this a new application? If so why are you using a framework that's been dead for about 10 years?

– Thomas
Nov 26 '18 at 8:52





Just out of curiosity: is this a new application? If so why are you using a framework that's been dead for about 10 years?

– Thomas
Nov 26 '18 at 8:52













@Thomas Ikr. But I have to. Because there is an application based on Struts 1 was implemented & used for many years (and still) by my company. I am instructed to implement I18N for it.

– Boosted Nub
Nov 26 '18 at 8:56





@Thomas Ikr. But I have to. Because there is an application based on Struts 1 was implemented & used for many years (and still) by my company. I am instructed to implement I18N for it.

– Boosted Nub
Nov 26 '18 at 8:56












1 Answer
1






active

oldest

votes


















0














If you don't find locale for your country and language in java.util.Locale as static constants, you can create them yourself like this,



Locale portugese = new Locale("pt","PT");
Locale swedish = new Locale("sv","SE");
Locale spanish = new Locale("es","ES");


There are variations based upon the country where the same language is spoken but above should be good.



This locale information may be helpful for you






share|improve this answer
























  • I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

    – Boosted Nub
    Nov 27 '18 at 0:49











  • You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:31













  • Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

    – Boosted Nub
    Nov 27 '18 at 4:43













  • You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:53








  • 1





    Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

    – Boosted Nub
    Nov 27 '18 at 6:26













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477430%2fhow-to-extend-unavailable-locale-language-by-default-in-action-controller%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














If you don't find locale for your country and language in java.util.Locale as static constants, you can create them yourself like this,



Locale portugese = new Locale("pt","PT");
Locale swedish = new Locale("sv","SE");
Locale spanish = new Locale("es","ES");


There are variations based upon the country where the same language is spoken but above should be good.



This locale information may be helpful for you






share|improve this answer
























  • I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

    – Boosted Nub
    Nov 27 '18 at 0:49











  • You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:31













  • Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

    – Boosted Nub
    Nov 27 '18 at 4:43













  • You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:53








  • 1





    Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

    – Boosted Nub
    Nov 27 '18 at 6:26


















0














If you don't find locale for your country and language in java.util.Locale as static constants, you can create them yourself like this,



Locale portugese = new Locale("pt","PT");
Locale swedish = new Locale("sv","SE");
Locale spanish = new Locale("es","ES");


There are variations based upon the country where the same language is spoken but above should be good.



This locale information may be helpful for you






share|improve this answer
























  • I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

    – Boosted Nub
    Nov 27 '18 at 0:49











  • You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:31













  • Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

    – Boosted Nub
    Nov 27 '18 at 4:43













  • You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:53








  • 1





    Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

    – Boosted Nub
    Nov 27 '18 at 6:26
















0












0








0







If you don't find locale for your country and language in java.util.Locale as static constants, you can create them yourself like this,



Locale portugese = new Locale("pt","PT");
Locale swedish = new Locale("sv","SE");
Locale spanish = new Locale("es","ES");


There are variations based upon the country where the same language is spoken but above should be good.



This locale information may be helpful for you






share|improve this answer













If you don't find locale for your country and language in java.util.Locale as static constants, you can create them yourself like this,



Locale portugese = new Locale("pt","PT");
Locale swedish = new Locale("sv","SE");
Locale spanish = new Locale("es","ES");


There are variations based upon the country where the same language is spoken but above should be good.



This locale information may be helpful for you







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 '18 at 8:57









Pushpesh Kumar RajwanshiPushpesh Kumar Rajwanshi

10.7k21229




10.7k21229













  • I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

    – Boosted Nub
    Nov 27 '18 at 0:49











  • You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:31













  • Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

    – Boosted Nub
    Nov 27 '18 at 4:43













  • You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:53








  • 1





    Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

    – Boosted Nub
    Nov 27 '18 at 6:26





















  • I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

    – Boosted Nub
    Nov 27 '18 at 0:49











  • You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:31













  • Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

    – Boosted Nub
    Nov 27 '18 at 4:43













  • You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

    – Pushpesh Kumar Rajwanshi
    Nov 27 '18 at 4:53








  • 1





    Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

    – Boosted Nub
    Nov 27 '18 at 6:26



















I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

– Boosted Nub
Nov 27 '18 at 0:49





I created a locale object with constructor in the class with the way you've provided but Locale.PORTUGUESE still can't be resolved?

– Boosted Nub
Nov 27 '18 at 0:49













You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

– Pushpesh Kumar Rajwanshi
Nov 27 '18 at 4:31







You can't use Locale.PORTUGUESE as Locale class does not have any static variable PORTUGUESE declared which is why you are getting the error message. You need to replace Locale.PORTUGUESE with this new Locale("pt","PT") or declare this as static variable in your class and use or use it in this statement like this session.setAttribute("org.apache.struts.action.LOCALE", new Locale("pt","PT"));

– Pushpesh Kumar Rajwanshi
Nov 27 '18 at 4:31















Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

– Boosted Nub
Nov 27 '18 at 4:43







Console shows WARNING: Resource org/apache/struts/actions/LocalStrings_en.properties Not Found. and SEVERE: Action[/changeLocale] missing resource in key method map 'pt' as I defined the method for /changeLocale action as 'pt' in properties file.

– Boosted Nub
Nov 27 '18 at 4:43















You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

– Pushpesh Kumar Rajwanshi
Nov 27 '18 at 4:53







You may need to do additional configuration for the new locale (provide the resource file that contains Portuguese text for localization) you are trying to use. Its been over a decade since I last used struts, so I may not be exactly able to pin point and tell you how you could fix the problem. Try googling with the error and you should get some pointers for resolving your problem. But most likely my guess is you need to supply resource like just like LocalStrings_en.properties and for Portuguese it should be LocalStrings_pt.properties

– Pushpesh Kumar Rajwanshi
Nov 27 '18 at 4:53






1




1





Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

– Boosted Nub
Nov 27 '18 at 6:26







Okay so I found out the issue that caused the error. It was my careless mistake and not related with this. Anyway your answer did helped me out how to create Locate manually. Sincerely appreciate your assistance over here ;-)

– Boosted Nub
Nov 27 '18 at 6:26






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477430%2fhow-to-extend-unavailable-locale-language-by-default-in-action-controller%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin