German Umlaute in Translation in abp.io - abp

io Community,
I am using the build in translation. Within my json I have following translation:
Within my razor page I use it here:
However, the output is:
How can I avoid this (UTF?) problem?

Save your de.json file as UTF-8
Check out:
https://github.com/abpframework/abp/issues/4626
https://github.com/abpframework/abp/issues/2180#issuecomment-554852256

Related

reactjs i18n change translation on demand

I use i18n (react-i18next) in my react js application. Translation with language chooser etc works absolutly fine.
But now I want to change some texts programmatically on demand.
I tried this:
i18n.t('clinical:sde.export.studyTitle', {lng: "en"})
and
i18n.t('clinical:sde.export.studyTitle', {"en"})
It always returns the german string from current setting and not the "on demand" english text. Is there a solution to solve this?
Thanks in advance.
Your code should work, you need to check that the dynamic language is loaded (this what i18n.changeLanguage does).
I've made a simple test, and it works.
https://codesandbox.io/s/react-i18next-example-forked-ueng1?file=/src/app.js

Liferay 7.1 npm-react-module localization

I'm trying to include localization into my npm-react-module, but I have failed receiving the value for the corresponding key from the Langugage.properties file. It simply returns the key. I did some research but I couldn't find any source that would help me solve my problem.
In the code which I will show you bellow, I have included a Language.properties file into my module. In my portlet, I have included the needed configuration for the language properties. I have also tried to add a separate file for a specific locale, but that didn't help me either.
This is an example of my portlet configuration:
"javax.portlet.resource-bundle=content.Language"
This is an example content from my Language.properties file:
example-key=example-value
This is how I'm trying to access the value in my React Component:
<h1> {Liferay.Language.get('example-key')} </h1>
But it only returns "example-key" instead of "example-value".
In my view.jsp file I am able to retrieve the corresponding values using
<liferay-ui:message key='example-key'/>
I have tried this method: https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/localizing-your-portlet but it didn't work either. Did anyone get this to work properly in their npm-react-module? I really don't want to spend time implementing my own localization service. Thanks!
Liferay.Language.get('key') gets text replaced by the build mechanism. Therefore there is no actual object/class to do this. I have been trying to get this to work myself and have resolved that I will have to do internationalization on my own.
localizing is done only in build time meaning if you have a language
key that generated dynamicly , you can't localizate it or for example
if you get a key from api fetch and need to localizate it, you can't
beacuse Liferay localization method for react (
Liferay.Language.get("yourLanguageKey") ) its undefined in runtime and
you can't use it.
from: https://npm.io/package/liferay-react-runtime-localization

In CakePHP, can someone explain how __d() works, particularly in relation to how it is used in default.ctp?

Sorry this will be a super newbie question.
In the default.ctp layout file, towards the beginning there are two lines.
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
$cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
I've found the function for __d here which says it "Allows you to override the current domain for a single message lookup." I don't really understand what it means at all.
Additionally, I was able to do the same thing without throwing any errors by simply replacing the lines with
$cakeDescription = 'CakePHP: the rapid development php framework';
$cakeVersion = 'CakePHP ' . Configure::version();
Its used for making your application multilingual.
You can use the command Console/cake i18n extract to extract all the text strings(which is the second parameter in __d()) into a pot file, which you can then translate.
See this for more information about __d() https://book.cakephp.org/2.0/en/core-libraries/internationalization-and-localization.html#internationalizing-cakephp-plugins
And see this for more information about extracting the strings into pot files
https://book.cakephp.org/2.0/en/console-and-shells/i18n-shell.html

How to find i18next missing keys

I'm using i18next to internationalize my React web application with typescript. When I process the text, it outputs the following:
Running string extraction on source files
Finding source files to process
Running xgettext
Extracting text for language en
Translation file was found - merging translations
..............................
Read 1 old + 1 reference, merged 266, fuzzied 0, missing 30, obsolete 27.
Running xgettext
Extracting text for language fr
Translation file was found - merging translations
..............................
[... other languages]
So I have 30 keys that are missing, but somehow I can't find a way to know exactly which 30 string keys are missing...
The only way I can currently find a missing key is if I open the console of my browser and when one of my React components is rendered if it contains a missing key, it prints:
i18next::translator: missingKey en translation my_missing_string my_missing_string
(Yes it prints it twice on the same line)
But, I am not going to try and render every single possible component depending on use cases since we have over 300 different strings.
How is i18next able to tell me that 30 are missing but not able to show which ones, I must be missing somthing.
what extraction tool are you using? seems to be from some gettext implementation - not related to i18next...
try one of those:
https://github.com/i18next/i18next-parser
https://github.com/i18next/i18next-scanner
This solution proposes another approach, which works great for our team : using translation files as a type, to validate parameters of the translation function.
So instead of finding missing keys, TpeScript will be able to tell you that the key you just entered does not exist.

How to read __() in Cakephp .ctp files with poedit?

How do i use Poedit to read strings embedded in __(). It's a Cakephp .ctp file. At the moment it only works if i remove one underscore: _(). I know how to use the console but i want to use Poedit.
Catalog -> Properties -> Source keywords and add __, because unlike _ it is not xgettext's default.
Just guessing, BTW, because your question leaves a lot to be desired in terms of usable details.
Read the books page about i18n & i10n.
You have to use the shell to generate the catalogue files and you open these files with poedit not your template files. That's how it works.
Have a read how gettext works. Translating something is more than just replacing a string...
So to make it easier if you can't have your ctpo file parsed by poedit.
Open poedit, in the "files" => "preferences" check the extractors tabs, choose php for modification, add *.ctp to the extension lists.
Save and update your list, translations from ctp files should be there now.
Enjoy !
You should indeed use your console to generate a pot file but, for example, i'm working on a project where everything is online on a mutualised server, i don't have access to any console.

Resources