ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

i18n for Vue: translated text not loaded

Open miyasuta opened this issue 6 years ago • 4 comments

Describe the documentation issue

  • [X] Documentation is unclear
  • [ ] Documentation is incorrect
  • [ ] Documentation is missing
  • [ ] Other

Description of the issue I'm new to UI5 Web Components and Vue. I'm trying to implement i18n functionality by following the document below . https://sap.github.io/ui5-webcomponents/playground/docs/i18n/ I have cloned the sample project for Vue and added config as described in the document. https://github.com/SAP-samples/ui5-webcomponents-sample-vue

Here is my github repo.

The issue is, the console shows "PLEASE_WAIT", instead of the corresponding text (Please wait). image

I debugged getText function and found the variable "bundle" was receiving below html message.

sorry but ui5-webcomponents-sample-vue doesn't work properly without JavaScript enabled. Please enable it to continue.

image

The app runs on Chrome and for Chrome, JavaScript is enabled. Maybe some settings are missing for my project?

Regards, Mio

miyasuta avatar Sep 27 '20 08:09 miyasuta

Hi @miyasuta

Here you can check the Vue docs related to static assets.

What you can do in order to fix your problem is make the following file structure(in the above link it is explained why your dependencies should be in the src folder) image

In your App.vue file add the following lines in order to load translations correctly:

registerI18nBundle("myApp", {
				de: "./i18n/messagebundle_de.properties",
				en: "./i18n/messagebundle_en.properties",
			});

			await fetchI18nBundle("myApp");

			const bundle = getI18nBundle("myApp");

			const pleaseWait = bundle.getText("PLEASE_WAIT");
			console.log("Please wait in the current language is: ", pleaseWait);

fifoosid avatar Oct 14 '20 08:10 fifoosid

Hi @fifoosid .

Thank you for your comment. I tried your solution, but the still the same result. I have updated my GitHub repo. https://github.com/miyasuta/webcomponents-test If you have a working example, could you share the source?

Regards, Mio

miyasuta avatar Oct 17 '20 23:10 miyasuta

Hi @miyasuta

I have uploaded your code here. You can check the last commit in order to see how the translations are implemented.

fifoosid avatar Oct 19 '20 11:10 fifoosid

Hi Hi @fifoosid

Thanks for the code. I could see the translation working!

miyasuta avatar Oct 26 '20 10:10 miyasuta