Plugin i18n: Support for English language files?

Feed 8 posts, 4 voices

Avatar
13 posts

I’m in the process of adding i18n support to the TB_Contactform plugin to allow users to translate several message, labels etc. But I’d also like to add an English i18n file to allow for easy editing of default message, also in English. For example, it is likely that users will want to change the “Message was sent succesfully” default message to something that suits them better.

Right now, this doesn’t seem to work because only language files other than the default locale are considered. Is there any chance that there will be support for alternative language files for the default locale if they are present?

 
Avatar
70 posts

For example, it is likely that users will want to change the “Message was sent succesfully” default message to something that suits them better.

Why would someone want to do this? Make it right in the first place so no one will complain ;)

Just kidding
M

 
Avatar
1493 posts

Actually, I can recall one case where the ability to have an en-message.php file read would have been a great help. (There the issue was trying to accomodate a Kohana helper that used this approach into Frog’s plugin system.)

In this case, I think the point is that — however elegant and appropriate the original wording — this would allow for simple customization of existing strings. One could imagine, for instance:

'Message sent successfully.' => 'Let the bells ring and the banners fly!',

or whatever… ;)

 
Avatar
58 posts

I think about it (coz i started that theme ^^ ), and if you will define a massages before that placing it in base function, it will be achive.

For example:
$success_msg = __(‘Message was sent succesfully’);

function tb_contactform($mail,$mailCC,$success_msg,$etc){ …

This approach allows you to translate your entire website in one place.

And more. I can’t write a message on my language directly in plugin. It’s determined that the files in UTF-8 encoding not correctly handled by php (or apache, just don’t know). I talked about it here

 
Avatar
13 posts

David, that’s exactly what I was trying to say but you phrased it more eloquently. :)

The way i18n works now is’t very clean to begin with. Ideally, I‘d like to define constants in my plugin file, for example SUCCESS_MESSAGE and then define the contents of the SUCCESS_MESSAGE in en-message.php.
I believe that’s a more common approach to i18n implemented in phpBB for example.

 
Avatar
13 posts

So is there any comment on whether this can/should/will be implemented in Frog?

 
Avatar
1493 posts

So is there any comment on whether this can/should/will be implemented in Frog?

All it would require is commenting out line 70 of /frog/helpers/I18n.php:

if (I18n::getLocale() != DEFAULT_LOCALE)

I can only see advantages here, and can’t see any disadvantages. If there is no en-message.php file in the i18n directory, you will just get the default strings. If there is an en-message.php file, then you get the replacement strings.

For me, the advantages outweigh the disadvantages. But then again, I don’t know what the disadvantages are! :P If there are some, it would be good to know!

 
Avatar
1493 posts

…for example SUCCESS_MESSAGE and then define the contents of the SUCCESS_MESSAGE in en-message.php.

Well — you could do it that way, of course. But with Frog’s “Help us translate Frog!” feature, it would be better to simply put your default strings into the __('Construct') so that other translators will know better what to translate. (IMO, of course!)

 
Avatar
13 posts

Yeah, it’s really easy to do, but I’d like for this to be a default so that people won’t have to hack into the core for my plugin to work. Is there any chance that can happen anytime soon?