juek / CustomSections

Developer plugin for rapid prototyping of custom section types in Typesetter CMS
GNU General Public License v2.0
3 stars 7 forks source link

i18n array #38

Closed mahotilo closed 6 years ago

mahotilo commented 7 years ago

We have

self::$i18n['section']['lang'];
self::$i18n['editor']['lang'];

Does it corresponds to

$section_lang = array();
$editor_lang = array();

in en.php?

Looks like we always use only strings from $section_lang = array();

mahotilo commented 7 years ago

Another i18n question.

I want to do something like this in section.php

$section_lang = self::$i18n['section']['lang'];
...
$javascript = 'var $MYCART_LANG = '.json_encode($section_lang).';';

to pass strings into JS plugin. But I get an empty array.

If I load en.php directly in section.php all works fine

If I correctly understand, we need to initialize $i18n a bit earlier?

P.S. And sorry, I give you an enigma but I will be off-line for a couple of days:)

juek commented 7 years ago

Looks like we always use only strings from $section_lang = array();

They are only different if you are using Multi-Language Manager. If so, the editor will always use Typesetter's config language, while the content section will adopt the language of the current page.

juek commented 7 years ago

If I correctly understand, we need to initialize $i18n a bit earlier?

Absolutely correct. And fixed

juek commented 7 years ago

Does it corresponds to $section_lang = array(); $editor_lang = array();

No, there is only $section_lang The differentiation happens only when Multi-Language Manager's page language deviates from Typesetter's admin ui language.

edit/ Maybe needs explanation: The $section_lang array in /i18n/*.php may contain terms/translations for both editor components and page content output. With Multi-Language Manager running, pages may have different languages assigned. This way, for example, we can still have the admin UI running in english but the generated content will obey the page language, e.g. french, ukraininan, you name it --> So you will see the editor in english but the rendered page in french.

mahotilo commented 7 years ago

Thanks, all works. And I agree with yours vision of i18n. Word "section" simply misguided me.