Page 1 of 1

serendipity_event_usergallery fully translated into German

Posted: Sat Aug 23, 2008 10:41 pm
by dietmar-s9y
Hi!

I'm new to serendipity and fiddled with it about the last three days. Since I want to use s9y as both a blog system and a gallery, I experimented with several ways to add a photo gallery (Gallery2/Coppermine/serendipity_event_usergallery) and read some posts about it.

Although the serendipity_event_usergallery plugin is not the "state-of-the-art" way to include photos (no comment or rating functions etc...), it is very simple to handle. So I decided to use this for the first time.

This was the chance for me to fully translate the language file lang_de.inc.php into German, because it was only partly translated before.
Now I wanted to make my work available to the s9y community, so please tell me what to do ;) Who's responsible for the plugin; should I provide a link to the changed files...?

But before that I've to mention some notes about my changes:

1.
In the template file plugin_usergallery.tpl there were some words like "images", "Page", "of", "totaling" in English plain text. So I added the following lines to the language file(s):

Code: Select all

//Several consants used in the template (in German, for example)
@define('PLUGIN_EVENT_USERGALLERY_TPL_IMAGES', 'Bilder');
@define('PLUGIN_EVENT_USERGALLERY_TPL_TOTALING', 'insgesamt');
@define('PLUGIN_EVENT_USERGALLERY_TPL_OF', 'von');
@define('PLUGIN_EVENT_USERGALLERY_TPL_PAGE', 'Seite');
Does this conform with the s9y coding rules? (I'm referring to the fact that I added constants and the names convention of these.) Another question is if some of these constants should better be placed in serendipity_lang_XX.inc.php, because maybe they could be needed in other plugins or the core itself. I also searched the serendipity language file for some existing constants I could use but found no @define I needed (except "@define('IMAGE', 'Bild')").

2. In the template file I now consider the singular/plural forms of "image". So if a directory has exactly one image, it will output "image" (or "Bild"), else "images" (or "Bilder"). This means there are changes to the .tpl file, too.

3. What about the other existing language files (Japanese and Turkish)? There I added my constants, but there should be someone who translates them ;)

Regards,
dietmar

Re: serendipity_event_usergallery fully translated into Germ

Posted: Sun Aug 24, 2008 12:57 am
by garvinhicking
Hi!

Many thanks for getting involved! A full german translation for that plugin would of course be very helpful. :-)

About your questions:

1: That is a good catch. Hardcoded strings should not be here. The preferred way to substitute this would be a bit different though, because a word-by-word constant translation doesn't go so well with other foreign languages.

So inside the .tpl file we could rather replace this:

Code: Select all

(Page {$plugin_usergallery_current_page} of {$plugin_usergallery_total_pages}, totaling {$plugin_usergallery_total_count} images)
with

Code: Select all

({$CONST.PLUGIN_EVENT_USERGALLERY_PAGINATION|printf: $plugin_usergallery_current_page: $plugin_usergallery_total_pages: $plugin_usergallery_total_count})
and then use a constant definition like:

Code: Select all

@define('PLUGIN_EVENT_USERGALLERY_PAGINATION', 'Page %s of %s, totaling %s images');
I have not tried this, but it should basically work....maybe you can test it?

Adding these constants to the s9y core code would actually make it problematic, because the plugins should be mostly independent from internal variables. Otherwise, people would see nothing there if they only upgraded the plugin, but not their core s9y version.

BTW, a similiar constant exists for this in the core: PAGE_BROWSE_ENTRIES

2.
That sounds very convenient!

3.
You only need to add new language strings for plugins in the english language file. All other translations are based on the english file, because the plugin loads that file as a fallback.

If you can bundle up a ZIP file with the updated/changed files and put it somewhere where I can download it, I could easily upload your patch into the plugin for public use. :)

Regards,
Garvin

Posted: Sun Aug 24, 2008 4:43 pm
by dietmar-s9y
Hi Garvin!

Thanks for your reply. I made the changes like you suggested, and it seems to work fine. So I have only two constants:

Code: Select all

@define('PLUGIN_EVENT_USERGALLERY_TPL_IMAGES', 'Bilder');
@define('PLUGIN_EVENT_USERGALLERY_PAGINATION', 'Seite %s von %s, insgesamt %s Bilder');
Since I found out that the PAGINATION line will not appear if there is only one image in total, there is no need to consider the singular/plural form of "image" here.

Another issue I noticed is that the heading ($blogTitle??) of the blog is always "gallery". This seems to be independent from what you type in the config field "Display name". But I don't know where to search for this "error"... I only know that in the index.tpl file the following line

Code: Select all

{$head_title|@default:$blogTitle|truncate:20:" ...":true}
is responsible for showing the title. But I don't know where the word "gallery" comes from.
Could you help?

Regards,
dietmar

PS: Is it possible to attach images to posts (upload from own pc)?

Posted: Sun Aug 24, 2008 9:01 pm
by Don Chambers
dietmar-s9y wrote: Another issue I noticed is that the heading ($blogTitle??) of the blog is always "gallery". This seems to be independent from what you type in the config field "Display name". But I don't know where to search for this "error"... I only know that in the index.tpl file the following line

Code: Select all

{$head_title|@default:$blogTitle|truncate:20:" ...":true}
is responsible for showing the title. But I don't know where the word "gallery" comes from.
Could you help?
index.tpl will show the blog title if a page has no value for $head_title. The plugin appears to be setting $head_title to the name of the base directory:

Code: Select all

$serendipity['head_title']    = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('base_directory'));
Is that correct? Is "gallery" your folder name? I wonder if that would be more effective if it used 'title' instead of 'base_directory'. I don't use this plugin, so perhaps Garvin will offer his opinion.
dietmar-s9y wrote:PS: Is it possible to attach images to posts (upload from own pc)?
You can reference an image hosted somewhere else - these forums do not permit uploading your images directly to this site.

Posted: Mon Aug 25, 2008 9:50 pm
by dietmar-s9y
Hi!
Don Chambers wrote:Is that correct? Is "gallery" your folder name?
No, there's no folder "gallery"...

But I tried to replace 'base_directory' with 'title':

Code: Select all

$serendipity['head_title']    = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('title'));
And it seems to work fine! Now the display name set in the config page is shown in the blog title.

But I think I should first examine the code more carfully... Perhaps it's important to have get_config('base_directory') here... I don't know so far.

Posted: Thu Aug 28, 2008 12:19 am
by dietmar-s9y
Well, after doing some *RTFM*, especially about the Plugin API and Event Hooks of S9y, I figure out some things better :)

So I would explain the word "gallery" as a general term to show that we are in the base directory...
This means if you go to the config page and select the "all directories" option as the default dir, the s9y upload root folder (called "uploads") will be used, and "gallery" will be shown as blog title.
I found out that if I select a subfolder(!) as the default directory, it's directory name will be shown as blog title. So, this is not a bug, but a feature ;)

Unfornately, showing "gallery" when not having a subfolder as default directory, is, maybe, not acceptable for non-English users. So I suggest to replace

Code: Select all

if ($this->selected()) {
    $serendipity['head_title']    = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('base_directory'));
    $serendipity['head_subtitle'] = $serendipity['blogTitle'];
}
with

Code: Select all

if ($this->selected()) {
    if ($this->get_config('base_directory') == 'gallery') {
        $serendipity['head_title']    = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('title'));
    } else {
        $serendipity['head_title']    = preg_replace('@[^a-z0-9]@i', ' ',$this->get_config('base_directory'));
    }
    $serendipity['head_subtitle'] = $serendipity['blogTitle'];
}
Ok, ok, I know this falls in the category "fine tuning".... :D But for me it was a chance to learn how s9y works.

rgds,
dietmar-s9y

Posted: Mon Sep 01, 2008 9:07 pm
by dietmar-s9y
Thanks to Garvin for uploading the changes into CVS!

Regards,
Dietmar