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

Translating Tagging plugin

I'm trying to translate Tagging plugin.

I already translated everything, than this:

var TagSearch = gdn.definition('PluginsTaggingSearchUrl', false); var TagAdd = gdn.definition('PluginsTaggingAdd', false); $("#Form_Tags").tokenInput(TagSearch, { hintText: gdn.definition("TagHint", "Start to type..."), searchingText: '', // search text gives flickery ux, don't like searchDelay: 300, animateDropdown: false, minChars: 1, maxLength: 25, prePopulate: tags, dataFields: ["#Form_CategoryID"], allowFreeTagging: TagAdd });

I'm trying to translate " Start to type..." string, but I don't want to translate it directly from tagging.js, but let the hintText go in a var called from the main function in someway.

Any suggestion?

Any further information will be helpful.

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    From what I see I would try to add a definition for "TagHint" and see if it works, but I've not much knowledge about Vanillas js functions...

  • @R_J‌ Already tried, but it doesn't work.

    I'm in your same boat, I don't have so much knowledge about Javascript functions .

  • R_JR_J Ex-Fanboy Munich Admin

    Have you cleared the cache after adding the translation?

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    The issue is that the TagHint definition isn't being added by any controllers—take a look at https://github.com/vanillaforums/Garden/search?q=taghint

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

  • @R_J‌ Yes, I deleted the cache.

    @Kasper‌ How can I manage this like you did for wsyihtml5 localization or time ago plugins?

  • gdn.definition is nothing to do with locale. it is a way of passing information to the client. In this case nothign being passed, so it is returning a default.

    On the controller you would set like so

    $Sender->AddDefinition('TagHint', T('TagHint','Start to type...'));
    

    You would just need to to hook the controller.

    only T('TagHint','Start to type...') is related to locale.

    you would translate like so:

    $Definition['TagHint'] = 'Start to type...';
    

    grep is your friend.

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    @x00's explanation is spot on. Now you know what that funky...

    <!-- Various definitions for Javascript //-->
    <div id="Definitions" style="display: none;">
      [...]
    </div>
    

    ...is for :smile:

    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

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

  • Thank you so much guys. I fixed like @x00‌ said.

    I opened the file class.tagging.plugin.php and modified these lines:

    /** * Add javascript to the post/edit discussion page so that tagging autocomplete works. */ /** * Add javascript to the post/edit discussion page so that tagging autocomplete works. */ public function PostController_Render_Before($Sender) { $Sender->AddJsFile('jquery.tokeninput.js'); $Sender->AddJsFile('tagging.js', 'plugins/Tagging'); $Sender->AddDefinition('PluginsTaggingAdd', Gdn::Session()->CheckPermission('Plugins.Tagging.Add')); $Sender->AddDefinition('PluginsTaggingSearchUrl', Gdn::Request()->Url('plugin/tagsearch')); $Sender->AddDefinition('TagHint', T('TagHint','Start to type...'));
    I just added the line $Sender->AddDefinition('TagHint', T('TagHint','Start to type...')); around 539-540.

    Then just add this line to your locale:

    $Definition['TagHint'] = 'Start to type...';

    I will push a commit to Github as soon as I can.

    Hope will be helpful.

Sign In or Register to comment.