on 09-18-2006 3:56 PM
Hello,
I am trying to use a resource bundle as it shown in the tutorial for internationalization.
I get the following exception:
java.util.MissingResourceException: Can't find bundle for base name myPackage.myViewName.wdview, locale en.
What am I doing wrong ?
Thanks,
Ofir.
Please paste the code where you are trying to access. It is most likely that you have not placed your resource bundle at the proper place or you have not given a proper path for your resource bundle.
Regards,
Subramanian V.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Here is the code:
public void wdDoInit()
{
//@begin wdDoInit()
resouceHandler = WDResourceHandler.createResourceHandlerForCurrentSession();
resourceHandler.loadResourceBundle("mypackage.MyView.wdview", this.getClass().getClassLoader());
//@end
}
I have compared it again against the SAP help tutorial, and it seems fine, but I noticed another thing:
I opened the WebDynPro section in the content administration in the portal, and opened my application.
In the "Language Resources" tab, I can see available resources under my view.
When I select the line containing my view, and select the proper language in the bottom frame, I receive the following error message:
>>Failed to read resource bundle "mypackage/MyView.wdview" for locale "en". Check trace for details.
Any idea what could be the problem ?
Thanks,
Ofir.
When you say "mypackage.Myview.wdview" in
resourceHandler.loadResourceBundle("mypackage.MyView.wdview", this.getClass().getClassLoader());
I assume there is a directory called <b>mypackage </b>
which has a folder <b>Myview</b>.
Please ensure the (1) name of the file is wdview.properties and it (2)lies within the folder <b>Myview</b>
For detailed help , refer
http://help.sap.com/saphelp_nw04/helpdata/en/8e/7ce87a2aede645ae3cdc857b791590/frameset.htm
Regards,
Subramanian V.
Ofir,
Seems that you are confusing 2 techniques here:
1. Java-standard resource bundles, that requires either property file (set of key=value lines) or subclass of ResourceBundle class.
2. SAP-specific WD localization mechanism used for view localization, message pool, etc.
If you need to localize texts of view controls, run S2X editor for *.xlf file corresponding to MyView.wdview. You may switch to Package Browser (Java perspective) and double-click on *.xlf. Then you may create additional versions of this file for specific locale(s). The default one created is uses application default locale -- the one you choose when creating project.
Valery Silaev
EPAM Systems
Hi Subramanian,
> I assume there is a directory called <b>mypackage
> </b>
> which has a folder <b>Myview</b>.
No,
"mypackage" is the package name, "MyView" is the view name.
The suffix ".wdview", is added to the S2X file("MyView.wdview.properties") in the package browser.
I'm quoting from your attached link code example:
// Load the resource bundle <b>MyResourceBundle.properties</b> located
// in the package <b>com.sap.test</b> for locale set in the resource handler.
// Therefore, the resource handler also needs the classloader that has
// the package com.sap.test in its scope
resourceHandler.loadResourceBundle(<b>com.sap.test.MyResourceBundle</b>, this.getClass() );
Thanks,
Ofir.
Hi Ofir,
As Valery mentions, there is a confusion of two approaches:
a) Internationalisation using S2X
b) Using ResourceBundle
So before trying to attempt to solve your problem,
a) Kindly state what is the problem that you are trying to solve
b) What are the steps you have taken to try to solve this problem ?
Reference Material : https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/35f1e990-0201-0010-7a86-914036942779
I assume you are trying to translate your .xlf files.
If that is the case, you don't need to use loadResourceBundle at all. Just follow the steps in the reference material and you are through.
Regards,
Subramanian V.
Hi Subramanian,
To your questions:
At the moment I am trying to just use the resource bundle.
Eventually I would like to be able to translate texts in my application but that doesn't have anything to do with my current problem.
All I am trying to do is to display a component which displays text taken from a resource bundle.
Thanks,
Ofir.
(Sorry for the user mixup)
If you are just trying out ResourceHandler , then try this out :
a) Create a file called Resources_<lg>.properties where <lg> is your language. It should be of length 2 letters. For example, en or de or fr.
b) Make entries in the following way :
key1=value1
c) Copy this file in your Project --> src --> packages --> <your package>
<your package> --> com.sap.test
d) In your wdDoInit, write the following code:
IWDResourceHandler test = WDResourceHandler.createResourceHandlerForCurrentSession();
ResourceBundle rb = test.getResourceBundle("com.sap.test.Resources",this.getClass().getClassLoader());
wdComponentAPI.getMessageManager().reportSuccess("Value of key1 = " + rb.getString("key1"));
To translate texts present in files like <viewname>.wdview.xlf , you use S2X editor and textAccessor in conjunction and translate these values. This is not done using ResourceHandler or ResourceBundle.
Hope I am making things more clear now.
Regards,
Subramanian V.
Hi,
The procedure you suggested is the same procedure we used with plain jspDynPage programming, I've expected it to be different in webDynPro programming.
Am I not supposed to use the S2X editor to define me text constants (Key,Value pairs) relateless to the translation options, and if I'd like to also translate the same texts I'll make anothe S2x file with the proper language suffix ?
Thanks,
Ofir.
Hi Ofir,
If you are using the S2X editor, then you just need to follow the tutorial link which I provided earlier.
There is no need for loadResourceBundle.
a) You need to copy the <view>.wdview.xlf file and rename it to <view>.wdview_<lg>.xlf where <lg> is the 2-letter language name.
b) You then double click this new .xlf file and translate your words/sentences
c) You now need to instantiate a textAccessor object and get the value of text using textAccessor.getText("key");
Yes and what you say in the second paragraph is right.
Regards,
Subramanian V.
Reference material is not opening...
I pasted the code in the init method.....
Locale sessionLocale = WDResourceHandler.getCurrentSessionLocale();
IWDResourceHandler resourceHandler = WDResourceHandler.createResourceHandler(sessionLocale);
// Alternativlely, use the following method:
IWDResourceHandler secondResourceHandler =
WDResourceHandler.createResourceHandlerForCurrentSession();
// Load the resource bundle u201CMyResourceBundle.propertiesu201D located
// in the package u201Ccom.sap.testu201D for locale set in the resource handler.
// Therefore, the resource handler also needs the classloader that has
// the package u201Ccom.sap.testu201D in its scope
resourceHandler.loadResourceBundle( "com.sap.languages.MyResourceBundle", this.getClass() );
// get the message for the u201Cpress saveu201D button
String saveMessage = resourceHandler.getString( "press_save" );
Iam getting the error ....****Resource HAndler is not applicable***********
Plaese help me is there any need to do modifications in the code.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.