# |
Jun 22nd 2021, 12:22 |
david |
no, that works fine |
# |
Jun 22nd 2021, 12:21 |
kevin.pfeifer |
but when changing to english, you want to load the text from the `en/default.po` and it doesn't` |
# |
Jun 22nd 2021, 12:21 |
david |
in spanish there is no problem |
# |
Jun 22nd 2021, 12:21 |
david |
yes, that is |
# |
Jun 22nd 2021, 12:20 |
kevin.pfeifer |
so your spanish text is all good and if your current active language is spanish then everything is fine, right? |
# |
Jun 22nd 2021, 12:18 |
david |
so, if translation doesn't exists, I get the spanish string |
# |
Jun 22nd 2021, 12:18 |
david |
I only have "/en" translations |
# |
Jun 22nd 2021, 12:17 |
david |
my default lang is "es", so "/es" doesn't exists |
# |
Jun 22nd 2021, 12:17 |
kevin.pfeifer |
so do you have ```/src /Locale /en default.po /es default.po``` |
# |
Jun 22nd 2021, 12:14 |
david |
3 |
# |
Jun 22nd 2021, 12:14 |
kevin.pfeifer |
first of all, are you on cakephp 4 or 3? |
# |
Jun 22nd 2021, 12:14 |
david |
it is correct |
# |
Jun 22nd 2021, 12:13 |
kevin.pfeifer |
so you are outputting your text via `__('English')` but it is being translated because your current language not englisch |
# |
Jun 22nd 2021, 12:12 |
kevin.pfeifer |
i guess i know what the problem is |
# |
Jun 22nd 2021, 12:12 |
david |
Iterating the translations is not a problem, but when I am in a translation, I can't figure how to get the default language string |
# |
Jun 22nd 2021, 12:11 |
david |
yes, it should be different |
# |
Jun 22nd 2021, 12:10 |
kevin.pfeifer |
by "each language" i mean each "currently active language" |
# |
Jun 22nd 2021, 12:07 |
kevin.pfeifer |
and the text shown in your language dropdown should be different for each language, right? |
# |
Jun 22nd 2021, 12:05 |
david |
my current url es mydomain.com/en/categories and I want to change to to mydomain.com/es/categorias |
# |
Jun 22nd 2021, 12:04 |
david |
for example |
# |
Jun 22nd 2021, 12:03 |
kevin.pfeifer |
what do you mean by the current section? |
# |
Jun 22nd 2021, 12:00 |
david |
I want to change the language, but keep in the current section. So I need to know the url segment of the current url |
# |
Jun 22nd 2021, 11:58 |
david |
I am trying to do a dropdown menu for changing the language of the current url |
# |
Jun 22nd 2021, 11:56 |
kevin.pfeifer |
besides the fact, that multiple translation "keys" can have the same translation, so you could run into the problem, that your given "translated text" appears multiple times in your .po file |
# |
Jun 22nd 2021, 11:54 |
kevin.pfeifer |
maybe you try to fix a problem which can be done easier otherwise |
# |
Jun 22nd 2021, 11:53 |
kevin.pfeifer |
but what are you trying to accomplish with that? |
# |
Jun 22nd 2021, 11:52 |
kevin.pfeifer |
and search through that manually if you really really want to |
# |
Jun 22nd 2021, 11:52 |
kevin.pfeifer |
you can ge tthe whole translation package via ``` $translator = I18n::getTranslator(); $package = $translator->getPackage();``` |
# |
Jun 22nd 2021, 11:52 |
erwane |
the `__` function call ` ```I18n::getTranslator()->translate($singular, $args);``` You can set you own translator, who search in ALL pot files for string and return original. |
# |
Jun 22nd 2021, 11:50 |
erwane |
but it's very weird request ;) |
# |
Jun 22nd 2021, 11:50 |
erwane |
Maybe you can write you own translator |
# |
Jun 22nd 2021, 11:44 |
david |
If I set a locale in runtime via I18n::setLocale(), I can get the translation of a string. Is there any way to do in the inverse way? Given a translation, get the original string. |
# |
Jun 22nd 2021, 11:42 |
david |
morning :) |
# |
Jun 22nd 2021, 11:39 |
kevin.pfeifer |
But I guess all these structures have their meaning and reason, even if we sometimes don't get it instantly :) |
# |
Jun 22nd 2021, 11:39 |
kevin.pfeifer |
to be honest i too had to fiddle with these things quite some time till i got it working :) |
# |
Jun 22nd 2021, 11:38 |
neon1024 |
Success! Thanks again for the tips @kevin.pfeifer appreciate the help |
# |
Jun 22nd 2021, 11:35 |
neon1024 |
The fact that CookieCollection is immutable caught me out |
# |
Jun 22nd 2021, 11:21 |
neon1024 |
Might be time for a coffee break ,:) |
# |
Jun 22nd 2021, 11:19 |
neon1024 |
Oh, good spot |
# |
Jun 22nd 2021, 11:19 |
kevin.pfeifer |
you need to set the CookieColleciton on the response, not the request |
# |
Jun 22nd 2021, 11:19 |
kevin.pfeifer |
you mixed request and repsonse there FYI |