Forums

[Plugin: Sociable] i18n localization | translation @ frontend problem (6 posts)

  1. tarrero
    Member
    Posted 4 months ago #

    Hi!

    I'm experiencing some problems trying to translate Sociable plugin 3.2.3

    I've build the .po from sources, translated to Spanish es_ES, and uploaded both .po and .mo to the i18n folder within Sociable Plugin folder.

    I've found in the support some advice about.
    So first i've changed:

    sociable.php:32
    - global $sociablepluginpath;
    - load_plugin_textdomain('sociable', $sociablepluginpath);
    + $sociablei18npath = 'wp-content/plugins/sociable/i18n/';
    + load_plugin_textdomain('sociable', $sociablei18npath);

    With this change, the plugin seems to properly load the localization file.
    I know that because the "Admin Backend" is getting transated after the change, but ¡the frontend is still in English!

    I want "icon title-descriptions" to work.

    I've tried to "hard code" the translation into $sociable_known_sites array and it works, so... there must be something i don't know even notice :)

    Any advice will be wellcome.

    p.s.: If the developer (also any other) is interested in es_ES translation ¡write me!, i share.

  2. tarrero
    Member
    Posted 4 months ago #

    I've made some progress.

    Possibly it's not a plugin problem.
    Maybe it's my theme's problem.

    I explain why i think that:

    It seems that the following Hook is only executed when I'm on the Backend:
    - add_filter('init', 'sociable_init_locale');

    if i override the Hook and "hard code" the function, the translation works in both Backend and Frontend:

    + $sociablei18npath = 'wp-content/plugins/sociable/i18n/';
    + load_plugin_textdomain('sociable', $sociablei18npath);

    This "workaround" seems to be a bad idea...
    I would like to use Hooks, they are there for that, but i'm a bit lost.

    Thanks for reading! i'll be glad reading your suggestions :)
    excuse my poor english,
    Daniel

  3. tarrero
    Member
    Posted 4 months ago #

    i think i know why this happens!
    But if i'm right, nobody is getting Sociable translated in frontend!

    The localization file is loaded on "init" hook, but the array (with the 'localized' descriptions) is loaded when the plugin is included (before the localization is loaded).

    Following this guess i've modified sociable.php in this way:
    (maybe line numbers are not exact)

    sociable.php:36
    - add_filter('init', 'sociable_init_locale');
    + add_action('init', 'sociable_init_locale');

    later, in $sociable_known_sites, modify the description NOT to call tranlations (because they are not available yet)
    ej:
    sociable.php:142
    - 'description' => __('E-mail this story to a friend!','sociable'),
    + 'description' => 'E-mail this story to a friend!'),

    oh! but i lost my tranlations that way!!

    yes, but let the next modification to do the magic (translate when output, so the translations are already loaded):

    sociable.php:577
    - $description = $site['description'];
    + $description = __($site['description'],'sociable');

    i'm worry about updates...
    i'll contact the developer to see if he decides to include the patch!

    Regars to the audience :)
    Daniel

  4. tarrero
    Member
    Posted 4 months ago #

    other handycap found on this solution:

    you can't automaticly build the .po for the translation, because "__(" calls are "dinamycly" generated...

    so regex stop working properly...

    if someone follows me, don't forget to add each $sociable_known_sites['description'] to your .po file (if not, they will not be translated, no mayor problem at all).

    d

  5. pavelevap
    Member
    Posted 3 months ago #

    I tried to prepare translation file for Czech language, but I was not successful. Files sociable-cs_CZ are not used... Any help? Thank you very much...

  6. jmbolivar
    Member
    Posted 2 months ago #

    @tarrero I'm interested in the es_ES files. Is there a place I can download them from?
    On the other hand, do you know whether the bug was eventually fixed by the developer of the plugin? Tx! JM

Reply

You must log in to post.

About this Topic

Tags