Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jul 01, 2015 at 05:19 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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