cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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 Kudos

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 Kudos

Hi Raj,

you are the best!!!

it works!

thank you very much

Waldemar

Former Member
0 Kudos

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)