Member
Member
ctdlg   2024-11-29, 12:24
#1

Hello,
Can we define our own sentences in lang dictionaries.
As an update will erase Mo and Po files (zp-core/locale folder), can we create our own lang dictionaries in another folder ?

Administrator
Administrator
acrylian   2024-11-29, 12:30
#2

That is currently not possible for the core. itself. But if you use a custom theme it can have its own translation as can custom plugins.

Please see:

Member
Member
ctdlg   2024-11-29, 18:17
#3

The more I use Zenphoto, the more I find it fantastic !
I will add what I need to my theme, following your tutorials.

Administrator
Administrator
acrylian   2024-12-01, 15:54
#4

Thanks, glad to hear.

Member
Member
ctdlg   2024-12-04, 11:16
#5

I cannot load my translation file.

What I did : a file
/theme/mytheme/traductions.php
This file contains only words and sentences to translate.
These words and sentences are used in my album.php and image.php files.
My code to display - example, based on "next"

Then, using my terminal, I created a pot file :
xgettext --language=PHP --from-code=UTF-8 --output=traductions.pot traductions.php

Then, I opened this pot file using Poedit, translated my sentences, added version and author, compiled the MO
it is located in
/themes/mytheme/traductions/locale/fr_FR/LC_MESSAGES/

Po file contains lines like
msgid "Site created in 2018"
msgstr "Site créé en 2018"

I tried adding my translations in index.php, but without success :
bindtextdomain('/themes/mytheme/traductions', DIR . '/locale');
echo gettext("next") . "
";
echo dgettext("traductions", "Site created in 2018") . "
";

next is translated (Zenphoto translation), but not Site created (My translation.)
Textdomain is Zenphoto.

It is not clear for me how and where to add my own theme translations !

Administrator
Administrator
acrylian   2024-12-04, 11:46
#6

The location is wrong with /themes/mytheme/traductions/locale/fr_FR/LC_MESSAGES/.

It must be /themes/mytheme/locale/(…) and you also need to use the proper translating gettext_th() functions as also documented: https://www.zenphoto.org/news/translating-tutorial/#--theme-translations. A file like /theme/mytheme/traductions.php is not necessary, strings are used where they are used and parsed by Poedit for the catalogue.

https://docs.zenphoto.org/1.6.5/namespaces/default.html#function_gettext_th

Member
Member
ctdlg   2024-12-04, 17:14
#7

Thank you, acrylian.

My path was bad, and I used
gettext instead of gettext_th !
Now, it works (without adding bindtextdomain('/themes/mytheme/traductions', DIR . '/locale'); at the top of index.php)

It is more simple than what I thought !

Administrator
Administrator
acrylian   2024-12-04, 18:11
#8

Great, we tried to make that as simple as possible.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.