HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Translate in plugin Timeago

I use Timeago
I cant not translate word "about 1 day ago",..
please help me!

Comments

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited May 2013

    The easiest way to translate the strings would be to edit the following lines in js/jquery.timeago.js: https://github.com/kasperisager/Timeago/blob/master/js/jquery.timeago.js#L37-L49

    Let me know how it goes!

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    Timeago.js have translations yet: https://github.com/rmm5t/jquery-timeago/tree/master/locales

    Just include your locale in your page.

    @kasperisager, why not include them in the plugin? Locale can be derived automatically from vanilla configuration or from a plugin setting...

    There was an error rendering this rich post.

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    Lol, completely forgot about the locales! I'll see what I can do, thanks for the input @lifeisfoo - it's a great idea!

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • you could


    You can loop through locale definitions with a TimeAgo. prefix. and also have also defaults and send them to the client.

    grep is your friend.

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited May 2013

    Oh course @x00! I'm doing the same thing with regards to translatable JS string in my WordCount plugin which allows the plugin to be translated through normal Garden means. It's brilliant, thanks!

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited May 2013

    Awesomestuff, locale support is now included in version 1.3.

    P.S.: Just for the record, this is the gist of what I did...

    In your plugin file:

     public function Event($Sender)
     {
        $Locale = array(
            'String' => T('Translation'),
            'String' => T('Translation'),
            [...]
        );
    
        $Sender->AddDefinition('Locale', json_encode($Locale));
     }
    

    In the above, Event will have to be replaced with the event you'd like to utilize. I used Base_Render_Before in my plugin as the fuzzy timestamps are applied throughout Garden and it's applications. It would also be a good idea to prefix Locale with the name of your plugin, which I did in Timeago: TimeagoLocale - this simply to avoid clashes with other plugins.

    In your Javascript file:

    jQuery(function() {
       var Locale = $.parseJSON(gdn.definition('Locale'));
    
       console.log(Locale.String);
       // => 'Translation'
    });
    

    And finally in locale/da-DK.php (just an example locale):

    <?php if (!defined('APPLICATION')) exit();
    
    $Definition['Translation'] = 'Oversættelse';
    

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

Sign In or Register to comment.