cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to get a localized string from lokalized ressources via beanshell?

Former Member
0 Likes
294

Hi,

my next challenge

i defined some localized strings.

i wish to use the strings in my beanshell script.

the script should get the proper string for the current user language.

i can't find any solution for it.

i read i shoud read them directly from the database. is this right?

thank you for any tip.

Waldemar

Accepted Solutions (1)

Accepted Solutions (1)

former_member207877
Active Participant
0 Likes

Hello Waldemar,

As per my understanding what you are trying to get is the Value for the given resource Id in Localized resources through scritping

You can do as below.

public String LocalizedResourceValue(String resourceId) {

//createResourceId(java.lang.String bundle, java.lang.String resource)

resource = TypeFactory.createResourceId("zcustom", resourceId);

resourceRef = TypeFactory.createResourceReference(resource);

resourceValue = resourceRef.getValue(session);

return resourceValue;

}


resourceStringValue = LocalizedResourceValue("resource_id");


Pass the ID as string in above method and you will get the value given for the respective LR.

Regards,

Raj

Former Member
0 Likes

Hi Raj,

you are the best!!!

it works!

thank you very much

Waldemar

Former Member
0 Likes

Hey Raj,

createResourceId

public static ResourceIdIfc createResourceId(java.lang.String bundle, java.lang.String resource)

resource = TypeFactory.createResourceId("zcustom", resourceId);

resourceRef = TypeFactory.createResourceReference(resource);

resourceValue = resourceRef.getValue(session);

Here, the createResourceId method will return an object 'Resource' of type 'ResourceIdIfc'. Next you are calling reference method but from here I am getting lost.

1. what that will return?

2. getValue() is present in Interface: ResourceReferenceIfc but its not implemented in your code. So how will it return value?

Regards

Manish Agrawal

Answers (0)

Ask a Question
Top Q&A Solution Author