I18N and Import View

Hi,

I’ve used the CAF Tools Externalize Strings tool available in the Designer to achieve first version of the I18N.

It works almost ok. The major problem is when I have views that import other views. In this case the imported view is not correctly internationalized.

For instance in the text is shown:
???g11n.MultiSearch.Entity.pesquisa_de_entidades???:

So the MultiSearch is the imported view.

No errors are shown in the console.

So, any idea how to correct this problem?

Thanks in Advance

Hi,

One quick answer is to restore g11n.MultiSearch.Entity.pesquisa_de_entidades with the value from the .properties file.

It is normal not to have any error since "g11n.MultiSearch.Entity.pesquisa_de_entidades" is replaced with the value from the .properties file.

br,
Vlad

That’s an interesting one!

I haven’t tried this, but in the included view, do you also have externalized resources? If so, can you copy (duplicate) g11n.MultiSearch.Entity.pesquisa_de_entidades into the included view’s resource file?

The duplicate was not a good idea to me since I had to make double the translations.

So my correction of the problem was to change the keys into the Application file, I also changed the imported view to get the I18N from the Application and not from the imported view, this solved the problem

New Problem

I have in property file
g11n.MedicineContextInfo.default.desactivar=Deactivate
g11n.MedicineContextInfo.default.activar=Activate

Now in my view I want something like this:
#{MedicineContextInfo.portletResources[“g11n.MedicineContextInfo.default.#{MedicineContextInfoDefaultviewView.activateDeactivate}”]}

Basically I want to concat the result from the method activateDeactivate into the string “g11n.MedicineContextInfo.default”. However the second EL is never resolved and is simple appended to the String, which is not in the property file. As result this can not be correctly I18N.

Any idea how to solve this?

Thanks

Hi Herve,

I think in this case it is better to use the ternary operator in order to render a condition based on the value of a business field:

#{MedicineContextInfoDefaultviewView.activateDeactivate eq 'activar' ? MedicineContextInfo.portletResources["g11n.MedicineContextInfo.default.activar"] : MedicineContextInfo.portletResources["g11n.MedicineContextInfo.default.desactivar"]} 

However, I recommend that you have a boolean getter for the render condition:

public class  MedicineContextInfo{
   boolean getIsActive(){
     ....
   }
...
}

br,
Vlad

Hi

Thanks for you relpy.

I already thought about that solution but that does not cover all my problems. Additionally I have another problem. I have a table where one of the column is the name of the week (en: Monday, Tuesday…; pt: Segunda, Terça). So the best way in this case is to contact the String to be I18N
Property File
g11n.MedicineContextInfo.date.default.seg
g11n.MedicineContextInfo.date.default.ter
g11n.MedicineContextInfo.date.default.qua
g11n.MedicineContextInfo.date.default.qui.
etc

EL expression
I would like to have something like that
#{MedicineContextInfo.portletResources[“g11n.MedicineContextInfo.date.#{row.dayOfWeek}”]}.

For instance, JBoss contains a Concat function that works in EL, does CAF contains something similar?

I’m wondering how this problem is solved in CAF since this should be a normal problem.

Thanks in Advance

Hi,

I think than in your case the day of the week will be determined in the bean.

So, you should use I18N there.

public class  MedicineContextInfo{
   public String getCurrentDayOfWeek(){
    //determine current day
    // get the proper I18n message
   String  dayOfWeek =  ContextUtils.localizeMessage(ContextUtils.getFacesContext(), bundleName, key, null, false);
     ....
     return ...;
   }
...
}

[url]http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite7/My_webMethods/7-2_CAF_and_MWS_Java_API_Reference/com/webmethods/caf/faces/context/ContextUtils.html#localizeMessage(FacesContext,%20java.lang.String,%20java.lang.String,%20java.lang.Object[],%20boolean)[/url]

br,
Vlad

Yap, this solved the problem

Thanks for your help :wink: