ZenphotoCMS Forum
plugin for personnal translation - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Translating (https://forum.zenphoto.org/forum-8.html)
+--- Thread: plugin for personnal translation (/thread-13059.html)



plugin for personnal translation - vincent3569 - 22-09-2017

hi
I want to create a plugin to manage personnal translations needed on my website (and that can't be managed by multi-lingual site option).

can you explain what the general structure of this plugin have to be ?




plugin for personnal translation - acrylian - 22-09-2017

I am sorry, I don't fully understand what this plugin is meant to do.

If you are talking about extra translation/strong for your theme that are not part of the theme by default, you need to use an extended theme base translation. That's just the theme translation just with your custom additions. You get those easily by parsing it using Poedit again.

Or do you want to put these extra strings into a separate plugin? That would be possible of course although I think that overcomplicates things. In that case you would have just to create a plugin based translation.




plugin for personnal translation - vincent3569 - 22-09-2017

yes I have extra translations for my themes and I know how it works.

In my case, I want extra translations for my content (i.e for using in blockcode).
I don't know what I have to create in that plugin based translation (no admin interface, only some string to translate with gettext_pl().

can you point me i the right direction?




plugin for personnal translation - vincent3569 - 22-09-2017

fyi, this news have a wrong link : http://www.zenphoto.org/news/zenphoto-plugin-architecture-documented/

http://www.zenphoto.org/2008/04/zenphoto-plugin-architecture/ doesn't exist (but there is this link : http://www.zenphoto.org/news/zenphoto-plugin-architecture/)




plugin for personnal translation - acrylian - 22-09-2017

That post is from 2008 when we used WordPress. Of course the link is broken now, we don't go through all … But you found it anyway…

A plugn does not need to have a admin interface. Just put a function with strings or just an array within it that contains the gettexted strings to translated. Then create a plugin based translation and use calls of the function or array in your theme.

Instead of using codeblocks extensively I would recommend maybe to use the multiplelayout plugins or theme based custom functions. Codeblocks are nice for quick things but you easily forget what you used where..… Use codeblock only when really necessary.




plugin for personnal translation - vincent3569 - 22-09-2017

I read the documentation before asking my question :-)

what do mean by

use calls of the function or array in your theme

can you give me a dummy example?




plugin for personnal translation - vincent3569 - 22-09-2017

basically, my plugin have this structure:

`

`

it's ok for you?
with that, I can access to translated string in my pages/news where needed?




plugin for personnal translation - acrylian - 22-09-2017

That would be like I had in mind. translated_strings() would better be named getTranslatedString() (we generally use camel case in Zenphoto in case you want to follow that writing). and get a parameter to access a specific strings since you want to use this on your theme.

So like this:

function getTranslatedString($index) {
$strings = array(
gettext_pl('Hello World!', 'translations'),
gettext_pl('Hello World, again!', 'translations')
);
return $strings[$index];
}

$firststring = getTranslatedString(1);

And for more flexibility maybe add:

function printTranslatedString($index) {
echo getTranslatedString($index);
}

I also would recommend to use a class with static methods as a wrapper so your plugin will avoid possibly naming conflicts.

class vincentsStrings { //best match the plugin name somehow

static getString($index) {
(…)
}

}

$firststring = vincentsStrings::getString(1);