175 Posts
webcastor
10 years ago
Topic

Since SEBLOD is (almost) well rounded regarding multi-language usage, I wonder have anybody found a solution how to use placeholder attribute in multi-language scenario. JText does not parse placeholder text, so there should be another solution (other than creating alias fields for every language or even worse using JS onclick).

Get a VIP membership
4229 Posts
Kadministrator
10 years ago
0
Level 1

Hi,

you can do this using joomla functions, see here

http://www.joomla-wiki.de/dokumentation/Benutzer:Elkuku/Proyektz/EasyCreator/Language_handling/Javascript_translations

You would need to place JText::script('NAFU_HELLO_WORLD'); part into beforeRender plugin as it is php and use Joomla.JText._('NAFU_HELLO_WORLD') javascript directly in placeholder javascript.

175 Posts
webcastor
10 years ago
0
Level 1

Thank you Klas!

That was excellent input and I managed after few trial&errors to find a recipe that works for me:

- Create language overrides

- Add definitions in template index.php, just above the HEAD

<?php
JText::script('PH_ARTICLE_TITLE');
JText::script('PH_ARTICLE_LABEL1');
JText::script('PH_ARTICLE_LABEL2');
...
?>

</head>

- Add a simple code snippet in Script (JS) of the field

$("#art_title_backend").attr("placeholder", Joomla.JText._('PH_ARTICLE_TITLE'));

Similar code can be placed in other text fields, inserting/substituting just the field name and the override string.

P.S. Of course, since there is no need to duplicate override strings, it is perfectly ok to use COM_CCK_strings. However, as placeholders our labels can contain additional explanations, examples and so on.

58 Posts
rasch-dmd
7 years ago
2
Level 1

Hey webcastor, Hey klas,

there is another trick with a css class and a litte jquery.

Regards,

RaSchDMD

175 Posts
webcastor
7 years ago
1
Level 2

Even though I haven't tested it, I suppose your solution is very nice for automation, but you skipped to say where do you put various language translations for placeholder. I imagine it should be some label (a label one language each) in the same group, that should be language constrained.

58 Posts
rasch-dmd
7 years ago
0
Level 3

Hey webcastor,

the label is the placeholder. For example you put an "test" in it and you have a multilanguage site, the output of the placeholder is "COM_CCK_TEST". 

Then you have to translate it in your desired language files. In the english file en-GB.com_cck_default.ini with a COM_CCK_TEST="English test" and in the german file de-DE.com_cck_default.ini with a COM_CCK_TEST="Deutscher Test".

When you work only with one language, the output of the placeholder is "test" and you don‘t need to translate it.

Is it clear enough?

RaSchDMD

Get a Book for SEBLOD