diff --git a/serendipity_event_multilingual/.htaccess b/serendipity_event_multilingual/.htaccess new file mode 100644 index 00000000..a88a85c7 --- /dev/null +++ b/serendipity_event_multilingual/.htaccess @@ -0,0 +1,7 @@ + +Allow from all + + + +RewriteEngine Off + diff --git a/serendipity_event_multilingual/ChangeLog b/serendipity_event_multilingual/ChangeLog index 611b28e8..cd314deb 100644 --- a/serendipity_event_multilingual/ChangeLog +++ b/serendipity_event_multilingual/ChangeLog @@ -1,58 +1,85 @@ -2.15: Added new "langswitch" variable to allow users forcing to switch the frontend language based on the content language +2.20, 1.12: +---- -2.14: Added genpage event hook so that blogTitle/Description gets replaced in other instances - where entries are not fetched (i.e. 'archives') - -sidebar 1.11: Use proper "current url", thanks to timbalu + * Minor preparations for the Serendipity 2.0 Backend + * Fix missing Smarty object init + * Fix Smarty modifier "multilingual_lang" method name + * Fix constant PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH define(s) + * Added more usage documentary + * Added htaccess file for documentation file readability + * Added a new OK Constant for the backend entry language switch. + This needs a change in backend templates 2k11/admin/entries.inc.tpl + file with 2.0.2+. Watch out for current or upcoming changes in + https://github.com/s9y/Serendipity/commits/2.0/templates/2k11/admin/entries.inc.tpl + * Check and error a missing entryproperties database table index + and fix a wrong set config value + * Fix the force "langswitch" variable option to properly work on click, + as long as the Browsers SESSION holds + * Posted sidebar lang selection influences backend lang ... document dependencies + * Fix 'enry_title' Smarty var not using translation with Smarty3 versions in + non-tag mode and option "Tag translation of the blog title" set true. + We need to declare this option valid for banner title translations in non-tag mode too! + + +2.15: +---- + + * Added new "langswitch" variable to allow users forcing + to switch the frontend language based on the content language + +2.14: +---- + + * Added genpage event hook so that blogTitle/Description gets + replaced in other instances where entries are not fetched + (i.e. 'archives') + + * sidebar 1.11: Use proper "current url", thanks to timbalu 2.13: ---- -Add smarty modifier "multilingual_lang" that you can use like - -{$entry_category.category_name|@multilingual_lang|@escape} - -in templates, to replace possible {{...}} language variants. - -Also, by default parse such language constructs in the category name. - + * Add smarty modifier "multilingual_lang" that you can use like + {$entry_category.category_name|@multilingual_lang|@escape} + in templates, to replace possible {{...}} language variants. + Also, by default parse such language constructs in the category name. 2.11, 2.12: ---- -Patch to save drafts properly, by Martin Matuska -SF Bug #3047591 - -Patch to properly detect current language, by Martin Matuska -SF Bug #3047600 + * Patch to save drafts properly, by Martin Matuska + SF Bug #3047591 + * Patch to properly detect current language, by Martin Matuska + SF Bug #3047600 2.10: ---- -Allow to replace category names/descriptions for the header display + * Allow to replace category names/descriptions for the header display 2.9: ---- -Completely replace the broken regexp to use subparts now. + * Completely replace the broken regexp to use subparts now. 2.8: --- -Another regexp for replacements, look-behind and look-ahead. + * Another regexp for replacements, look-behind and look-ahead. 2.7: ---- -Better regexp for replacements + * Better regexp for replacements 2.6: ---- -Fix a PHP error notice + * Fix a PHP error notice 2.5: ---- -Allow for tagged trnaslations, see documentation. By praabjerg \ No newline at end of file + * Allow for tagged translations, see documentation. By praabjerg + \ No newline at end of file diff --git a/serendipity_event_multilingual/UTF-8/lang_bg.inc.php b/serendipity_event_multilingual/UTF-8/lang_bg.inc.php index db3b8f0e..5a89c010 100644 --- a/serendipity_event_multilingual/UTF-8/lang_bg.inc.php +++ b/serendipity_event_multilingual/UTF-8/lang_bg.inc.php @@ -1,4 +1,4 @@ -}}{{--}}'); +@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Zapne možnost překládání nadpisu pomocí taug {{!}}{{--}}. Also used for non-tag mode translated entry_title(s).'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES', 'Překládání příspěvků a nadpisů příspěvků pomocí tagů v textu'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES_DESC', 'Zapne možnost překládání příspěvků pomocí tagu {{!}}{{--}}'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR', 'Překládání položek postranních sloupců pomocí tagů'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR_DESC', 'Zapne možnost překládání obsahu postranních sloupců pomocí tagu {{!}}{{--}}'); // Next lines were translated on 2013/10/26 -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH', 'Vynutit plné přepnutí jazyka?'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH_DESC', 'Má se při vybrání jazykové verze jednotlivého příspěvku přepnout do zvoleného jazyka kompletně i celé rozhraní blogu?'); \ No newline at end of file +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH', 'Vynutit plné přepnutí jazyka?'); +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH_DESC', 'Má se při vybrání jazykové verze jednotlivého příspěvku přepnout do zvoleného jazyka kompletně i celé rozhraní blogu?'); + diff --git a/serendipity_event_multilingual/UTF-8/lang_cz.inc.php b/serendipity_event_multilingual/UTF-8/lang_cz.inc.php index 4d657b21..5fca87d4 100644 --- a/serendipity_event_multilingual/UTF-8/lang_cz.inc.php +++ b/serendipity_event_multilingual/UTF-8/lang_cz.inc.php @@ -39,12 +39,13 @@ // Next lines were translated on 2009/08/25 @define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE', 'Překládání nadpisu příspěvku pomocí tagů'); -@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Zapne možnost překládání nadpisu pomocí taug {{!}}{{--}}'); +@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Zapne možnost překládání nadpisu pomocí taug {{!}}{{--}}. Also used for non-tag mode translated entry_title(s).'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES', 'Překládání příspěvků a nadpisů příspěvků pomocí tagů v textu'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES_DESC', 'Zapne možnost překládání příspěvků pomocí tagu {{!}}{{--}}'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR', 'Překládání položek postranních sloupců pomocí tagů'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR_DESC', 'Zapne možnost překládání obsahu postranních sloupců pomocí tagu {{!}}{{--}}'); // Next lines were translated on 2013/10/26 -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH', 'Vynutit plné přepnutí jazyka?'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH_DESC', 'Má se při vybrání jazykové verze jednotlivého příspěvku přepnout do zvoleného jazyka kompletně i celé rozhraní blogu?'); \ No newline at end of file +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH', 'Vynutit plné přepnutí jazyka?'); +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH_DESC', 'Má se při vybrání jazykové verze jednotlivého příspěvku přepnout do zvoleného jazyka kompletně i celé rozhraní blogu?'); + diff --git a/serendipity_event_multilingual/UTF-8/lang_de.inc.php b/serendipity_event_multilingual/UTF-8/lang_de.inc.php index c46c8533..2a996ab6 100644 --- a/serendipity_event_multilingual/UTF-8/lang_de.inc.php +++ b/serendipity_event_multilingual/UTF-8/lang_de.inc.php @@ -1,18 +1,17 @@ - diff --git a/serendipity_event_multilingual/UTF-8/lang_fr.inc.php b/serendipity_event_multilingual/UTF-8/lang_fr.inc.php index 9bd2ab37..ae8c01c2 100644 --- a/serendipity_event_multilingual/UTF-8/lang_fr.inc.php +++ b/serendipity_event_multilingual/UTF-8/lang_fr.inc.php @@ -1,4 +1,4 @@ - diff --git a/serendipity_event_multilingual/UTF-8/lang_ko.inc.php b/serendipity_event_multilingual/UTF-8/lang_ko.inc.php index 721e11a8..6311d878 100644 --- a/serendipity_event_multilingual/UTF-8/lang_ko.inc.php +++ b/serendipity_event_multilingual/UTF-8/lang_ko.inc.php @@ -1,20 +1,20 @@ - # (c) 2005 http://www.tool-box.info/ - @define('PLUGIN_EVENT_MULTILINGUAL_TITLE', '다중 언어로 글 작성'); - @define('PLUGIN_EVENT_MULTILINGUAL_DESC', '여러 언어 버전으로 된 글을 작성할 수 있습니다'); - @define('PLUGIN_EVENT_MULTILINGUAL_NEEDTOSAVE', '다른 언어 버전을 추가하기 전에 먼저 글을 저장해야 합니다. 초안으로 저장해도 됩니다.'); - @define('PLUGIN_EVENT_MULTILINGUAL_CURRENT', '편집할 언어 버전을 고르십시오: '); - @define('PLUGIN_EVENT_MULTILINGUAL_SWITCH', '언어 선택'); - @define('PLUGIN_EVENT_MULTILINGUAL_COPY', '이전 언어 내용 보존'); - @define('PLUGIN_EVENT_MULTILINGUAL_COPYDESC', '새 언어 버전을 작성할 때 이전 언어로 작성된 내용을 입력창에 유지시킴'); +@define('PLUGIN_EVENT_MULTILINGUAL_TITLE', '다중 언어로 글 작성'); +@define('PLUGIN_EVENT_MULTILINGUAL_DESC', '여러 언어 버전으로 된 글을 작성할 수 있습니다'); +@define('PLUGIN_EVENT_MULTILINGUAL_NEEDTOSAVE', '다른 언어 버전을 추가하기 전에 먼저 글을 저장해야 합니다. 초안으로 저장해도 됩니다.'); +@define('PLUGIN_EVENT_MULTILINGUAL_CURRENT', '편집할 언어 버전을 고르십시오: '); +@define('PLUGIN_EVENT_MULTILINGUAL_SWITCH', '언어 선택'); +@define('PLUGIN_EVENT_MULTILINGUAL_COPY', '이전 언어 내용 보존'); +@define('PLUGIN_EVENT_MULTILINGUAL_COPYDESC', '새 언어 버전을 작성할 때 이전 언어로 작성된 내용을 입력창에 유지시킴'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_TITLE', '언어 선택'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_DESC', '방문자가 메인 페이지의 언어를 변경할 수 있게 하기'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_USERDESC', '이 블로그가 표시되는 언어를 다른 것으로 바꿀 수 있습니다: '); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT', 'Submit 버튼'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC', 'Submit 버튼을 표시합니까?'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_SIZE', '글꼴 크기'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_TITLE', '언어 선택'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_DESC', '방문자가 메인 페이지의 언어를 변경할 수 있게 하기'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_USERDESC', '이 블로그가 표시되는 언어를 다른 것으로 바꿀 수 있습니다: '); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT', 'Submit 버튼'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC', 'Submit 버튼을 표시합니까?'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SIZE', '글꼴 크기'); -?> \ No newline at end of file diff --git a/serendipity_event_multilingual/UTF-8/lang_tr.inc.php b/serendipity_event_multilingual/UTF-8/lang_tr.inc.php index d230f4f5..d7b46838 100644 --- a/serendipity_event_multilingual/UTF-8/lang_tr.inc.php +++ b/serendipity_event_multilingual/UTF-8/lang_tr.inc.php @@ -1,4 +1,4 @@ - diff --git a/serendipity_event_multilingual/documentation_de.html b/serendipity_event_multilingual/documentation_de.html new file mode 100644 index 00000000..b078f61d --- /dev/null +++ b/serendipity_event_multilingual/documentation_de.html @@ -0,0 +1,50 @@ + + + + + Tagged translation + + +

Getagte Übersetzungen

+ +

Das multilingual Plugin kann Übesetzungen per tag mittels {{!<lang>}}<text>{{--}} bereitstellen. Will man  zum Beispiel eine englische und eine dänische Version des Textes anbieten, so schreibt man: "{{!en}}English version of text{{--}}{{!da}}Dansk version af tekst{{--}}" in das input Feld.

+ +

Getagte Übersetzungen haben den Vorteil, dass sie u.a. auch in der Seitenleiste verwendbar sind, so dass jeder editierbare Inhalt (in der Regel der Titel) von einem Seitenleisten Element auch übersetzt werden kann. Dies erstreckt sich per Option auch auf den Blog-Titel und Untertitel.

+ +

Auch Theme eigene Optionen wie eine Navigationsleiste könnten so einfachst für verschiedenen Sprachen multilingual genutzt werden. Allerdings muss dann per Handarbeit der Smarty Modifier "|multilingual_lang" der entsprechenden Ausgabevariable in der Theme eigenen index.tpl per {$navlink.title|multilingual_lang} hinzugefügt werden.

+ +

Eine getagte Übersetzungen für Blog Einträge kann ebenfalls benutzt werden, ist aber in den Plugin Optionen standardmäßig deaktiviert, da sie bereits im Plugin vorhandene Funktionalität dupliziert. Getagte Übersetzungung sind bereits durch die Verwendung eines Datenbank basierten Ansatzes implementiert, und sie sollten entscheiden, welche Vorgehensweise sie beim Erstellen ihrer Einträge bevorzugen. Mit der gleichzeitigen Benutzung von beiden Ansätzen könnten am Ende seltsame und verwirrende Funktionalitäten enstehen. Die per default genutzte Datenbank basierende Methode nutzt das entryproperties Plugin das installiert sein muss. Hier wird der Eintrag in der default Blogsprache wie bisher auch erstellt und gespeichert. Dann kann man denselben Eintrag nutzen, übersetzen und mittels des neuen Sprachauswahlfeldes in der neuen Sprache abspeichern. Die übersetzte Variante befindet sich nun als entryproperties Eintrag in der entryproperties Tabelle. Im Frontend kann ein einzelner Blogeintrag mittels eines "Footer Links" leicht in der Sprache gewechselt werden. Dieses Verfahren hat keine Auswirkungen auf die Darstellung des Blogs, so wie es das Sprachen-Auswahlfeld des Seitenleisten Plugins hat, außer man aktiviert dies als Option. Zugriff auf die übersetzte Variante des Eintrags im Backend erhält man, in dem der originale Default Sprach Eintrag wie gewohnt aufgerufen, dann aber mit Hilfe des Sprach-Auswahlfeldes und des Buttons "Sprache wechseln" in den bereits übersetzten Eintrag gewechselt wird.

+ +

Beachten sie auch, dass eine getagte Übersetzung mittels des Multilinguial Plugins nur tatsächliche Sprachblöcke betrifft, andere Sprachen aber keinen Fallback haben, so dass dieser Sprachteil dann immer leer zurückgegeben wird. Das heißt, sie sollten immer nur so viele Sprachen im Seitenleisten Plugin erlauben, wie sie auch als tag zur Übersetzung tatsächlich zur Verfügung stellen.

+ +

Für Staticpages nutzen sie bitte das dort eingebaute Sprachen Auswahl Feld und erstellen damit jeweils eine eigene Staticpage per Sprache! Diese wird bei der Darstellung im Frontend je nach eingestellter Sprache automatisch erkannt. Dies ist unterschiedlich zum oben genannten Blog Eintragsverfahren! Sprach: 'ALL' Felder in den statische Seiten werden überall angezeigt.

+ +

Zusammengefasst haben sie die folgenden Möglichkeiten mit diesem Plugin:

+ +
    +
  1. Inhalte von input Feldern per "tag" automatisiert multilingual bereitstellen
  2. +
  3. Ausgewählte input Felder per "tag" und Smarty modifier automatisch übersetzbar machen
  4. +
  5. Blog Einträge per "tag" multilingual gestalten (per default deaktiviert, zugunsten von)
  6. +
  7. Blog Einträge via Datenbank und entryproperties event Plugin multilingual erstellen und verwalten
  8. +
  9. Andersprachige Staticpages geben sich generell unabhängig von Multilingual Plugin, sind aber abhängig von der verwendeten Blogsprache
  10. +
  11. Multilinguale nuggets können per eigenem Plugin (serendipity_plugin_nugget_multilingual) erstellt werden
  12. +
+ +

Abhängigkeiten für:

+ +
    +
  • (4) - Installiertes serendipity_event_entryproperties Plugin.
  • +
  • (3) - Hier ist es sicher auch eine Notwendigkeit, das Markup Plugin: "NL2BR" für diese Einträge generell oder per Entry zu deaktivieren. Ansonsten werden Zeilenumbrüche außerhalb von Sprachblöcken zu <br /> tags umgewandelt und dargestellt.
  • +
+ +

Bitte beachten sie auch:

+ +
+

Wenn die Option "Sprache des Browsers eines Besuchers verwenden" in Serendipity aktiviert ist, überschreibt diese die aktuelle Spracheinstellung - und die aktuelle Spracheinstellung ist immer das, was Serendipity als "default" Spracheinstellung darstellt und auslegt. Es obliegt den Blog Autoren streng darauf zu achten, dass derjenige immer mit demselben Setup in der Spracheinstellung agiert, wenn ein Eintrag editiert wird. Ansonsten kann es zu unvorhergesehenen Problemen und sogar Eintragsverlusten führen.

+
+
+

Zusätzlich sollten sie als Admin des Blogs, die "Globale Konfigurations" Blog Sprach-Variable und die "Persönliche Einstellungen" Sprach-Variable gleich setzen und weiterhin im Frontend keine Seitenleiste Sprach-Selektion setzen. Ansonsten kann es durch das gesetzte Cookie zu unvorhergesehenen Problemen in der Sprachdarstellung kommen.

+
+ + + \ No newline at end of file diff --git a/serendipity_event_multilingual/documentation_en.html b/serendipity_event_multilingual/documentation_en.html index fe68e574..4b8482c8 100644 --- a/serendipity_event_multilingual/documentation_en.html +++ b/serendipity_event_multilingual/documentation_en.html @@ -1,15 +1,50 @@ - + + -Tagged translation + + Tagged translation -

Tagged translation

-The multilingual plugin now supports tagged translations by the use of {{!<lang>}}<text>{{--}} tags. So if you want to write text with an english and a danish version, for instance, you can write: "{{!en}}English version of text{{--}}{{!da}}Dansk version af tekst{{--}}". -

-Tagged translation has the advantage of being usable in the sidebar. So any editable content (typically the title) of a sidebar item can be translated as well. It even extends to the blog title and subtitle. -

-Tagged translation for entries is also available, but is disabled by default, as it duplicates functionality already present in the plugin. Entry translation is already implemented by use of a database based approach, and you should decide on which approach you prefer when creating entries. Using both approaches at the same time could end up being weird and confusing. Also be aware that tagged translation works by simply stripping out any language blocks that are not the current language. This means that you should probably disable the Markup: NL2BR plugin for entries. Otherwise newlines outside language blocks will be converted to </br> tags and included. +

The multilingual plugin supports tagged translations by the use of {{!<lang>}}<text>{{--}} tags. So if you want to write text with an english and a danish version, for instance, you can write: "{{!en}}English version of text{{--}}{{!da}}Dansk version af tekst{{--}}" into the input field.

+ +

Tagged translation have the advantage of being usable in the sidebar for example. So any editable content (typically the title) of a sidebar item can be translated as well. It even extends to the blog title and subtitle.

+ +

Also theme based options like a navigation bar may be used tagged multilingual very easily. For this case you have to manually edit your themes index.tpl and add the Smarty Modifier "|multilingual_lang" to the variables in question per {$navlink.title|multilingual_lang}.

+ +

Tagged translation for blog entries is also available, but is disabled by default, as it duplicates functionality already present in the plugin. Entry translation is already implemented by use of a database based approach, and you should decide on which approach you prefer when creating entries. Using both approaches at the same time could end up being weird and confusing. The database implemented method uses the entryproperties plugin, which has to be installed first. Using this default method you have to write and save your entry as ever in the default blogs language. Then you can use the same entry, translate its content and title, select the language in the new language select field and save the entry again. This translated entry variant is now saved to the entryproperties database table. In the blogs frontend you can easily switch the translation variant by entry in the entries footer language links. This entry based lang switch has no change inheritance to the general blogs language, like the sidebar languagechooser field has, if not set by option. To get access to the translated entry version in the backend, open the origin lang blog entry in the entry form, select the translated language and hit the button "Select language". This will bring up the translated entry variant. Now you can edit and save this entry in purpose.

+ +

Also be aware that tagged translation works by simply stripping out any language blocks that are not the current language. There is no fallback language in this case and means to only allow that much languages for the users to switch in the sidebar, that you already tagged.

+ +

For staticpages use its language select field and emit one single staticpage per language! This will be automatically evaluated in the frontend language. This is handled differently to the blog entry approach! Lang 'ALL' field staticpages are shown in any case.

+ +

In summary you have these possibilities with this plugin:

+ +
    +
  1. Content of input fields per "tag" automatically translated multilingual
  2. +
  3. Make certain content of input fields per "tag" and manually added Smarty modifier multilingual
  4. +
  5. Write blog entries per "tag" multilingual (per default disabled, in favour of)
  6. +
  7. Make blog entries translation available via database and the entryproperties event plugin
  8. +
  9. Non default language Staticpages are independent from this multilingual plugin, but are depending on the blogs language
  10. +
  11. Multilinguale nuggets can be set set independently by another plugin (serendipity_plugin_nugget_multilingual)
  12. +
+ +

Dependencies for:

+ +
    +
  • (4) - Installed serendipity_event_entryproperties plugin.
  • +
  • (3) - This means that you should probably disable the Markup plugin: "NL2BR" for entries in general or per entry. Otherwise newlines outside language blocks will be converted to <br /> tags and included.
  • +
+ +

Please also pay attention to:

+ +
+

If the "browser language detection" option is enabled in Serendipity, this actually overrides the current language - and the current language is always what Serendipity displays and describes as "default" language. It currently actually relies on the blog editors to have the same setup of their language whenever they edit an article, else it would lead into problems or may loose data.

+
+
+

As the blogs Admin, better set the "Global Configuration" Blog language and the "Personal Preferences" language to the same language. Further on, do not use the sidebars language selection in the frontend. Elsewise the language cookie set, can lead to unwanted language problems overall.

+
+ - + \ No newline at end of file diff --git a/serendipity_event_multilingual/lang_bg.inc.php b/serendipity_event_multilingual/lang_bg.inc.php index 62df7d28..e4456d63 100644 --- a/serendipity_event_multilingual/lang_bg.inc.php +++ b/serendipity_event_multilingual/lang_bg.inc.php @@ -1,4 +1,4 @@ -}}{{--}}'); +@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Zapne monost pekldn nadpisu pomoc taug {{!}}{{--}}. Also used for non-tag mode translated entry_title(s).'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES', 'Pekldn pspvk a nadpis pspvk pomoc tag v textu'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES_DESC', 'Zapne monost pekldn pspvk pomoc tagu {{!}}{{--}}'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR', 'Pekldn poloek postrannch sloupc pomoc tag'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR_DESC', 'Zapne monost pekldn obsahu postrannch sloupc pomoc tagu {{!}}{{--}}'); // Next lines were translated on 2013/10/26 -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH', 'Vynutit pln pepnut jazyka?'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH_DESC', 'M se pi vybrn jazykov verze jednotlivho pspvku pepnout do zvolenho jazyka kompletn i cel rozhran blogu?'); \ No newline at end of file +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH', 'Vynutit pln pepnut jazyka?'); +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH_DESC', 'M se pi vybrn jazykov verze jednotlivho pspvku pepnout do zvolenho jazyka kompletn i cel rozhran blogu?'); + diff --git a/serendipity_event_multilingual/lang_cz.inc.php b/serendipity_event_multilingual/lang_cz.inc.php index 6f7b62d7..6d767729 100644 --- a/serendipity_event_multilingual/lang_cz.inc.php +++ b/serendipity_event_multilingual/lang_cz.inc.php @@ -39,12 +39,13 @@ // Next lines were translated on 2009/08/25 @define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE', 'Pekldn nadpisu pspvku pomoc tag'); -@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Zapne monost pekldn nadpisu pomoc taug {{!}}{{--}}'); +@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Zapne monost pekldn nadpisu pomoc taug {{!}}{{--}}. Also used for non-tag mode translated entry_title(s).'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES', 'Pekldn pspvk a nadpis pspvk pomoc tag v textu'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES_DESC', 'Zapne monost pekldn pspvk pomoc tagu {{!}}{{--}}'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR', 'Pekldn poloek postrannch sloupc pomoc tag'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR_DESC', 'Zapne monost pekldn obsahu postrannch sloupc pomoc tagu {{!}}{{--}}'); // Next lines were translated on 2013/10/26 -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH', 'Vynutit pln pepnut jazyka?'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH_DESC', 'M se pi vybrn jazykov verze jednotlivho pspvku pepnout do zvolenho jazyka kompletn i cel rozhran blogu?'); \ No newline at end of file +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH', 'Vynutit pln pepnut jazyka?'); +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH_DESC', 'M se pi vybrn jazykov verze jednotlivho pspvku pepnout do zvolenho jazyka kompletn i cel rozhran blogu?'); + diff --git a/serendipity_event_multilingual/lang_de.inc.php b/serendipity_event_multilingual/lang_de.inc.php index 838f25a6..6ef3e624 100644 --- a/serendipity_event_multilingual/lang_de.inc.php +++ b/serendipity_event_multilingual/lang_de.inc.php @@ -1,18 +1,17 @@ - diff --git a/serendipity_event_multilingual/lang_en.inc.php b/serendipity_event_multilingual/lang_en.inc.php index 9dc9065a..4bf8de36 100644 --- a/serendipity_event_multilingual/lang_en.inc.php +++ b/serendipity_event_multilingual/lang_en.inc.php @@ -1,4 +1,4 @@ -}}{{--}} tags for blog title'); +@define('PLUGIN_EVENT_MULTILINGUAL_TAGTITLE_DESC', 'Enable {{!}}{{--}} tags for blog title. Also used for non-tag mode translated entry_title(s).'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES', 'Tag translation of entries and entry titles'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGENTRIES_DESC', 'Enable {{!}}{{--}} tags for entries'); @define('PLUGIN_EVENT_MULTILINGUAL_TAGSIDEBAR', 'Tag translation of sidebar items'); @@ -26,17 +26,18 @@ @define('PLUGIN_EVENT_MULTILINGUAL_PLACE_ADDFOOTER', 'Footer of an entry'); @define('PLUGIN_EVENT_MULTILINGUAL_PLACE_ADDSPECIAL', '"multilingual_footer" for custom Smarty output'); +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH', 'Force full language switch?'); +@define('PLUGIN_EVENT_MULTILINGUAL_LANGSWITCH_DESC', 'Choosing a translation for a blog entry will also switch the whole language of the blog?'); + +@define('PLUGIN_EVENT_MULTILINGUAL_ENTRY_RELOADED', 'Multilingual entry language <%s> reloaded'); + // // serendipity_plugin_multilingual.php // @define('PLUGIN_SIDEBAR_MULTILINGUAL_TITLE', 'Choose Language'); @define('PLUGIN_SIDEBAR_MULTILINGUAL_DESC', 'Allows visitors to change the frontend interface language'); @define('PLUGIN_SIDEBAR_MULTILINGUAL_USERDESC', 'You can select a different language for the displayed interface of this blog: '); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT', 'Submit button?'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC', 'Show a submit button?'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT', 'Submit button?'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC', 'Show a submit button?'); @define('PLUGIN_SIDEBAR_MULTILINGUAL_SIZE', 'Font size'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH', 'Force full language switch?'); -@define('PLUGIN_SIDEBAR_MULTILINGUAL_LANGSWITCH_DESC', 'Choosing a translation for a blog entry will also switch the whole language of the blog?'); - -?> diff --git a/serendipity_event_multilingual/lang_fr.inc.php b/serendipity_event_multilingual/lang_fr.inc.php index 08645a52..6ef709eb 100644 --- a/serendipity_event_multilingual/lang_fr.inc.php +++ b/serendipity_event_multilingual/lang_fr.inc.php @@ -1,4 +1,4 @@ - diff --git a/serendipity_event_multilingual/lang_ko.inc.php b/serendipity_event_multilingual/lang_ko.inc.php index 1331e2bb..6311d878 100644 --- a/serendipity_event_multilingual/lang_ko.inc.php +++ b/serendipity_event_multilingual/lang_ko.inc.php @@ -1,20 +1,20 @@ - # (c) 2005 http://www.tool-box.info/ - @define('PLUGIN_EVENT_MULTILINGUAL_TITLE', '다중 언어로 글 작성'); - @define('PLUGIN_EVENT_MULTILINGUAL_DESC', '여러 언어 버전으로 된 글을 작성할 수 있습니다'); - @define('PLUGIN_EVENT_MULTILINGUAL_NEEDTOSAVE', '다른 언어 버전을 추가하기 전에 먼저 글을 저장해야 합니다. 초안으로 저장해도 됩니다.'); - @define('PLUGIN_EVENT_MULTILINGUAL_CURRENT', '편집할 언어 버전을 고르십시오: '); - @define('PLUGIN_EVENT_MULTILINGUAL_SWITCH', '언어 선택'); - @define('PLUGIN_EVENT_MULTILINGUAL_COPY', '이전 언어 내용 보존'); - @define('PLUGIN_EVENT_MULTILINGUAL_COPYDESC', '새 언어 버전을 작성할 때 이전 언어로 작성된 내용을 입력창에 유지시킴'); +@define('PLUGIN_EVENT_MULTILINGUAL_TITLE', '다중 언어로 글 작성'); +@define('PLUGIN_EVENT_MULTILINGUAL_DESC', '여러 언어 버전으로 된 글을 작성할 수 있습니다'); +@define('PLUGIN_EVENT_MULTILINGUAL_NEEDTOSAVE', '다른 언어 버전을 추가하기 전에 먼저 글을 저장해야 합니다. 초안으로 저장해도 됩니다.'); +@define('PLUGIN_EVENT_MULTILINGUAL_CURRENT', '편집할 언어 버전을 고르십시오: '); +@define('PLUGIN_EVENT_MULTILINGUAL_SWITCH', '언어 선택'); +@define('PLUGIN_EVENT_MULTILINGUAL_COPY', '이전 언어 내용 보존'); +@define('PLUGIN_EVENT_MULTILINGUAL_COPYDESC', '새 언어 버전을 작성할 때 이전 언어로 작성된 내용을 입력창에 유지시킴'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_TITLE', '언어 선택'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_DESC', '방문자가 메인 페이지의 언어를 변경할 수 있게 하기'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_USERDESC', '이 블로그가 표시되는 언어를 다른 것으로 바꿀 수 있습니다: '); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT', 'Submit 버튼'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC', 'Submit 버튼을 표시합니까?'); - @define('PLUGIN_SIDEBAR_MULTILINGUAL_SIZE', '글꼴 크기'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_TITLE', '언어 선택'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_DESC', '방문자가 메인 페이지의 언어를 변경할 수 있게 하기'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_USERDESC', '이 블로그가 표시되는 언어를 다른 것으로 바꿀 수 있습니다: '); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT', 'Submit 버튼'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SUBMIT_DESC', 'Submit 버튼을 표시합니까?'); +@define('PLUGIN_SIDEBAR_MULTILINGUAL_SIZE', '글꼴 크기'); -?> diff --git a/serendipity_event_multilingual/lang_tr.inc.php b/serendipity_event_multilingual/lang_tr.inc.php index 5c2a266c..5fd7b2db 100644 --- a/serendipity_event_multilingual/lang_tr.inc.php +++ b/serendipity_event_multilingual/lang_tr.inc.php @@ -1,4 +1,4 @@ - diff --git a/serendipity_event_multilingual/serendipity_event_multilingual.php b/serendipity_event_multilingual/serendipity_event_multilingual.php index a4f66b86..0d269868 100755 --- a/serendipity_event_multilingual/serendipity_event_multilingual.php +++ b/serendipity_event_multilingual/serendipity_event_multilingual.php @@ -1,5 +1,4 @@ -add('name', PLUGIN_EVENT_MULTILINGUAL_TITLE); - $propbag->add('description', PLUGIN_EVENT_MULTILINGUAL_DESC); - $propbag->add('stackable', false); - $propbag->add('author', 'Garvin Hicking, Wesley Hwang-Chung'); - $propbag->add('requirements', array( + $propbag->add('name', PLUGIN_EVENT_MULTILINGUAL_TITLE); + $propbag->add('description', PLUGIN_EVENT_MULTILINGUAL_DESC); + $propbag->add('stackable', false); + $propbag->add('author', 'Garvin Hicking, Wesley Hwang-Chung'); + $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', 'php' => '4.1.0' )); - $propbag->add('groups', array('FRONTEND_ENTRY_RELATED', 'BACKEND_EDITOR')); - $propbag->add('version', '2.15.1'); - $propbag->add('configuration', array('copytext', 'placement', 'tagged_title', 'tagged_entries', 'tagged_sidebar', 'langswitch')); + $propbag->add('groups', array('FRONTEND_ENTRY_RELATED', 'BACKEND_EDITOR')); + $propbag->add('version', '2.20'); + $propbag->add('configuration', array('copytext', 'placement', 'tagged_title', 'tagged_entries', 'tagged_sidebar', 'langswitch')); $propbag->add('event_hooks', array( - 'frontend_fetchentries' => true, - 'frontend_fetchentry' => true, - 'entry_display' => true, - 'backend_publish' => true, - 'backend_save' => true, - 'backend_display' => true, - 'frontend_entryproperties' => true, - 'backend_sidebar_entries' => true, - 'external_plugin' => true, - 'css' => true, - 'backend_entryform' => true, - 'backend_entry_presave' => true, - 'backend_entry_updertEntry' => true, - 'frontend_entries_rss' => true, - 'frontend_comment' => true, - 'frontend_sidebar_plugins' => true, - 'genpage' => true, + 'frontend_fetchentries' => true, + 'frontend_fetchentry' => true, + 'entry_display' => true, + 'backend_publish' => true, + 'backend_save' => true, + 'backend_display' => true, + 'frontend_entryproperties' => true, + 'backend_sidebar_entries' => true, + 'external_plugin' => true, + 'css' => true, + 'backend_entryform' => true, + 'backend_entry_presave' => true, + 'backend_entry_updertEntry' => true, + 'frontend_display' => true, + 'frontend_entries_rss' => true, + 'frontend_comment' => true, + 'frontend_sidebar_plugins' => true, + 'genpage' => true, )); $this->supported_properties = array('lang_selected','lang_display'); $this->dependencies = array('serendipity_plugin_multilingual' => 'remove'); @@ -67,6 +67,17 @@ class serendipity_event_multilingual extends serendipity_event header('X-Serendipity-ML-LD-1: ' . $this->cleanheader($this->lang_display)); } + // GET is either a forced session or a single entry lang we normally do not use it with cookies set, since they have preference + if (serendipity_db_bool($this->get_config('langswitch')) && (!isset($_POST['user_language']) || !isset($_COOKIE['serendipityLanguage']))) { + // check for REQUESTs being sent (imagine the user in a DE blog links an EN entry version and force option is set TRUE) + // $_REQUEST was somehow disabled and not available, but used here and in serendipity_getSessionLanguage() + $_REQUEST['user_language'] = $serendipity['GET']['user_language']; + // normal fallback + if (!isset($serendipity['GET']['lang_selected']) && !isset($_REQUEST['user_language'])) { + if (!empty($_SESSION['serendipityLanguage'])) $this->showlang = $_SESSION['serendipityLanguage']; + } + } elseif (!isset($_COOKIE['serendipityLanguage'])) $resetlang = true; // force == false and we only want the translated article, nothing else being touched multilingual + if (empty($this->showlang) && isset($serendipity['POST']['properties']['lang_selected'])) { $this->showlang = serendipity_db_escape_string($serendipity['POST']['properties']['lang_selected']); $_SESSION['last_lang'] = $this->showlang; @@ -76,14 +87,46 @@ class serendipity_event_multilingual extends serendipity_event $_SESSION['last_lang'] = $this->showlang; serendipity_header('X-Serendipity-ML-SL-2: ' . $this->cleanheader($this->showlang)); } elseif (empty($this->showlang) && isset($_REQUEST['user_language'])) { - $this->showlang = $_REQUEST['user_language']; + $this->showlang = serendipity_db_escape_string($_REQUEST['user_language']); serendipity_header('X-Serendipity-ML-SL-3: ' . $this->cleanheader($this->showlang)); } elseif (empty($this->showlang) && isset($_REQUEST['serendipity']['serendipityLanguage'])) { - $this->showlang = $_REQUEST['serendipity']['serendipityLanguage']; + $this->showlang = serendipity_db_escape_string($_REQUEST['serendipity']['serendipityLanguage']); serendipity_header('X-Serendipity-ML-SL-4: ' . $this->cleanheader($this->showlang)); } elseif (empty($this->showlang) && isset($serendipity['lang']) && !isset($_SESSION['last_lang'])) { - $this->showlang = $serendipity['lang']; - serendipity_header('X-Serendipity-ML-SL-5: ' . $this->cleanheader($this->showlang)); + $this->showlang = $serendipity['lang']; + serendipity_header('X-Serendipity-ML-SL-5: ' . $this->cleanheader($this->showlang)); + } + + // case reset TRUE without POST cookies + if ($resetlang && !isset($_COOKIE['serendipityLanguage'])) { + $serendipity['lang'] = $this->showlang = $_SESSION['serendipityLanguage'] = $_SESSION['last_lang'] = $serendipity['default_lang']; // reset strictly to default global language + } + // case force langswitch to default, normally without POST cookies set, since they have preference + if (serendipity_db_bool($this->get_config('langswitch')) && (!isset($_POST['user_language']) || !isset($_COOKIE['serendipityLanguage']))) { + // a user has already set a forced language and now wants to return to the default language - doing such here after all, avoids a doubleclick need.. + if ($this->showlang == 'default' || $_SESSION['last_lang'] == 'default') { + $serendipity['lang'] = $this->showlang = $_SESSION['serendipityLanguage'] = $_REQUEST['user_language'] = $serendipity['default_lang']; + if ($_SESSION['last_lang'] == 'default') $_SESSION['last_lang'] = $serendipity['default_lang']; + } // the entry is shown in default language as a fallback, when another language is chosen that has no entryproperties translation + } + // case repair cookie array + if (isset($_COOKIE['serendipity']['serendipityLanguage'])) { + $_COOKIE['serendipityLanguage'] = $_COOKIE['serendipity']['serendipityLanguage']; + unset($_COOKIE['serendipity']); + } + // case POST set cookies mean, always check cookies to set current lang! + if (isset($_COOKIE['serendipityLanguage'])) { + // reset all langs strictly to default global hold COOKIE language + $serendipity['lang'] = $this->showlang = $_SESSION['serendipityLanguage'] = $_SESSION['last_lang'] = $serendipity['default_lang'] = $_COOKIE['serendipity']['serendipityLanguage'] = $_COOKIE['serendipityLanguage']; + $this->lang_display = ''; // need this to always get the correct set lang and be the default in case of fallback and default + } + + // case unforced language entry lang links + if (isset($serendipity['GET']['lang_selected']) && !isset($serendipity['GET']['user_language'])) { + $this->lang_display = $this->showlang = $serendipity['GET']['lang_selected']; + } + if ($serendipity['GET']['lang_selected'] == 'default' && !isset($serendipity['GET']['user_language'])) { + $this->lang_display = ''; // sets entry lang to default } if (!isset($serendipity['languages'][$this->showlang])) { @@ -105,8 +148,18 @@ class serendipity_event_multilingual extends serendipity_event $built = $this->get_config('db_built', null); if (empty($built)) { $q = "@CREATE {FULLTEXT_MYSQL} INDEX fulltext_idx on {$serendipity['dbPrefix']}entryproperties (value);"; + if (serendipity_db_schema_import($q)) { + $this->set_config('db_built', 2); + } + } + $q = "SHOW INDEX FROM {$serendipity['dbPrefix']}entryproperties FROM {$serendipity['dbName']}"; + if (!is_array(serendipity_db_query($q))) { + echo ' Error: '.$r.'. Does it exist? Please check your privileges to this table; triggered in serendipity_event_multilingual, setupDB() method.'; + } else $this->set_config('db_built', 3); + if ($built != 4) { + $q = "DELETE FROM {$serendipity['dbPrefix']}config WHERE name LIKE '%serendipity_event_multilingual/db_built%'"; serendipity_db_schema_import($q); - $this->set_config('db_built', 2); + $this->set_config('db_built', 4); } } @@ -175,19 +228,19 @@ class serendipity_event_multilingual extends serendipity_event function urlparam($key) { static $langswitch = null; - + if ($langswitch === null) { $langswitch = serendipity_db_bool($this->get_config('langswitch')); } - + if ($langswitch) { // user_language return 'serendipity[lang_selected]=' . $key . '&serendipity[user_language]=' . $key; } else { return 'serendipity[lang_selected]=' . $key; - } + } } - + function &getLang($id, &$properties) { global $serendipity; static $default_lang = null; @@ -218,42 +271,43 @@ class serendipity_event_multilingual extends serendipity_event } else { $default_lang_sql = serendipity_db_query("SELECT value FROM {$serendipity['dbPrefix']}config WHERE name = 'lang'", true, 'assoc'); if (is_array($default_lang_sql)) { - $default_lang = $serendipity['languages'][$default_lang_sql['value']]; + $default_lang = $serendipity['languages'][$default_lang_sql['value']]; } else { - $default_lang = USE_DEFAULT; + $default_lang = USE_DEFAULT; } } } if (!isset($langs[$default_lang])) { $langs[$default_lang] = '' . $default_lang . ''; - } + } $lang = implode(', ', $langs); return $lang; } //function neglang($lang) { - function neglang($lang, $assert = '?!') { + function neglang($lang, $assert = '?!') { /* Creates the negation pattern from a two letter language identifier. */ // Negative look ahead assertion. ".*" is used because any letter except of the language string shall be allowed, without it, nothing woud ever match */ return '(' . $assert . $lang . ').*'; //return '(?!' . $lang . ').*'; - + //return '[^'.$lang[0].'][^'.$lang[1].']'; } function strip_langs($msg) { global $serendipity; - + if (!preg_match('@{{@', $msg)) return $msg; - $language = $serendipity['lang']; + #$language = $serendipity['lang']; // disabled - nowhere used so far + /* Handle escaping of {} chars. If someone is up for it, they're welcome to try and find a better way. As it is, this appears to work. */ $msg = str_replace('\{', chr(1), $msg); $msg = str_replace('\}', chr(2), $msg); - + // The explode actually makes sure that each latter array part will end on either the full string end or {{--}}. {{--}} will also never be contained inside the string, so we don't need to rule it out any longer. $parts = explode('{{--}}', $msg); $out = ''; @@ -281,27 +335,32 @@ class serendipity_event_multilingual extends serendipity_event function tag_title() { global $serendipity; - if (serendipity_db_bool($this->get_config('tagged_title', 'true'))) { - - if ($serendipity['smarty']) { - $serendipity['smarty']->assign('blogTitle',$this->strip_langs($serendipity['blogTitle'])); - $serendipity['smarty']->assign('blogDescription',$this->strip_langs($serendipity['blogDescription'])); - $head_title = $serendipity['smarty']->get_template_vars('head_title'); - if (!empty($head_title)) { - $serendipity['smarty']->assign('head_title',$this->strip_langs($head_title)); - } + if (serendipity_db_bool($this->get_config('tagged_title', 'true'))) { - $head_subtitle = $serendipity['smarty']->get_template_vars('head_subtitle'); - if (!empty($head_subtitle)) { - $serendipity['smarty']->assign('head_subtitle',$this->strip_langs($head_subtitle)); - } - } else { - $serendipity['blogTitle'] = $this->strip_langs($serendipity['blogTitle']); - $serendipity['blogDescription'] = $this->strip_langs($serendipity['blogDescription']); - } - } + if (is_object($serendipity['smarty'])) { + $serendipity['smarty']->assign('blogTitle',$this->strip_langs($serendipity['blogTitle'])); + $serendipity['smarty']->assign('blogDescription',$this->strip_langs($serendipity['blogDescription'])); + if ($serendipity['version'][0] < 2) { + $head_title = $serendipity['smarty']->get_template_vars('head_title'); + $head_subtitle = $serendipity['smarty']->get_template_vars('head_subtitle'); + } else { + $head_title = $serendipity['smarty']->getTemplateVars('head_title'); + $head_subtitle = $serendipity['smarty']->getTemplateVars('head_subtitle'); + } + + if (!empty($head_title)) { + $serendipity['smarty']->assign('head_title',$this->strip_langs($head_title)); + } + if (!empty($head_subtitle)) { + $serendipity['smarty']->assign('head_subtitle',$this->strip_langs($head_subtitle)); + } + } else { + $serendipity['blogTitle'] = $this->strip_langs($serendipity['blogTitle']); + $serendipity['blogDescription'] = $this->strip_langs($serendipity['blogDescription']); + } + } } - + function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; @@ -311,8 +370,8 @@ class serendipity_event_multilingual extends serendipity_event case 'backend_entry_updertEntry': if (isset($serendipity['POST']['no_save'])) { - $eventData["error"] = true; - } + $eventData['error'] = true; + } return true; break; @@ -369,11 +428,20 @@ class serendipity_event_multilingual extends serendipity_event break; case 'genpage': - $this->tag_title(); - - if ($serendipity['smarty']) { - $serendipity['smarty']->register_modifier('multilingual_lang', array($this, 'strip_lang')); + if (!is_object($serendipity['smarty'])) { + serendipity_smarty_init(); } + if (!defined('Smarty::SMARTY_VERSION')) { + $this->tag_title(); // in Smarty 2 only + // check this deeply! - since at least for the non-tag banner entry_title this seems to not work here with Smarty 3 - see workaround in frontent_display + } + + if ($serendipity['version'][0] < 2) { + $serendipity['smarty']->register_modifier('multilingual_lang', array($this, 'strip_langs')); + } else { + $serendipity['smarty']->registerPlugin('modifier', 'multilingual_lang', array($this, 'strip_langs')); + } + return true; break; @@ -432,10 +500,23 @@ class serendipity_event_multilingual extends serendipity_event .serendipity_multilingualInfo a:hover { color: green; } + showlang]) && + serendipity_db_bool($this->get_config('tagged_title', 'true')) && + $serendipity['view'] == 'entry') + { + $serendipity['smarty']->assign('head_title', $eventData['title']); + } + break; + case 'entry_display': if (!is_array($eventData)) { return false; @@ -487,23 +568,25 @@ class serendipity_event_multilingual extends serendipity_event if ($langs = $this->getLang($eventData[$i]['id'], $eventData[$i]['properties'])) { $eventData[$i][$place] .= sprintf($msg, $langs); + // this may throw two for the same, eg. when already linked as , them set to POST cookie too in the sidebar selection. + // In this case the lang link and the default lang link are both named 'english' } } } // Tagged translation of Blog title and description $this->tag_title(); - + if (serendipity_db_bool($this->get_config('tagged_entries', 'true'))) { foreach ($eventData as $key => $entry) { if (isset($eventData[$key]['title'])) { - $eventData[$key]['title'] = $this->strip_langs($eventData[$key]['title']); - $eventData[$key]['body'] = $this->strip_langs($eventData[$key]['body']); - if (is_array($eventData[$key]['categories'])) { - foreach($eventData[$key]['categories'] AS $ec_key => $ec_val) { - $eventData[$key]['categories'][$ec_key]['category_name'] = $this->strip_langs($ec_val['category_name']); + $eventData[$key]['title'] = $this->strip_langs($eventData[$key]['title']); + $eventData[$key]['body'] = $this->strip_langs($eventData[$key]['body']); + if (is_array($eventData[$key]['categories'])) { + foreach($eventData[$key]['categories'] AS $ec_key => $ec_val) { + $eventData[$key]['categories'][$ec_key]['category_name'] = $this->strip_langs($ec_val['category_name']); + } } - } - } + } } } return true; @@ -523,21 +606,32 @@ class serendipity_event_multilingual extends serendipity_event foreach($use_lang AS $code => $desc) { $langs .= '' . "\n"; } + if ($serendipity['version'][0] < 2) { ?>
+
+
+ +
+ -
- - + + +
get_config('tagged_entries', 'true'))) { $serendipity['smarty']->assign('head_title', $this->strip_langs($serendipity['head_title'])); @@ -662,6 +757,7 @@ class serendipity_event_multilingual extends serendipity_event } return true; break; + case 'frontend_sidebar_plugins': if (serendipity_db_bool($this->get_config('tagged_sidebar', 'true'))) { foreach ($eventData as $key => $entry) { diff --git a/serendipity_event_multilingual/serendipity_plugin_multilingual.php b/serendipity_event_multilingual/serendipity_plugin_multilingual.php index ff441e6d..538e8056 100644 --- a/serendipity_event_multilingual/serendipity_plugin_multilingual.php +++ b/serendipity_event_multilingual/serendipity_plugin_multilingual.php @@ -1,11 +1,10 @@ -add('configuration', $conf); - $propbag->add('version', '1.11.1'); + $propbag->add('version', '1.12'); $propbag->add('groups', array('FRONTEND_VIEWS')); $this->dependencies = array('serendipity_event_multilingual' => 'remove'); } function introspect_config_item($name, &$propbag) { global $serendipity; - + foreach($serendipity['languages'] AS $lkey => $lval) { if ($name == $lkey) { - $propbag->add('type', 'boolean'); - $propbag->add('name', $lval); - $propbag->add('default', 'true'); - return true; + $propbag->add('type', 'boolean'); + $propbag->add('name', $lval); + $propbag->add('default', 'true'); + return true; } } - + switch($name) { case 'title': $propbag->add('type', 'string'); @@ -69,14 +68,14 @@ class serendipity_plugin_multilingual extends serendipity_event $propbag->add('default', 'false'); break; - case 'size': + case 'size': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MULTILINGUAL_SIZE); $propbag->add('default', '9'); break; default: - return false; + return false; } return true; } @@ -85,18 +84,19 @@ class serendipity_plugin_multilingual extends serendipity_event global $serendipity; $title = $this->get_config('title', $this->title); - $url = serendipity_currentURL(true); + $url = serendipity_currentURL(true); echo '
'; echo ''; - if ($this->get_config('show_submit', 'false') == 'true') { + if (serendipity_db_bool($this->get_config('show_submit', 'false'))) { echo ''; } echo '
';