Skip to content

i18n #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
marcioaguiar opened this issue Jun 5, 2013 · 18 comments
Open

i18n #16

marcioaguiar opened this issue Jun 5, 2013 · 18 comments
Labels
enhancement pending review This issue was closed as stale; since then additional review has been requested. pull request welcome
Milestone

Comments

@marcioaguiar
Copy link

Suport for multiple languages.

Text to create new item is hardcoded english.

@brianreavis
Copy link
Member

I think this would be an easy thing to address... might as well. In the meantime, you can always provide a render.option_create function in the settings to custom-render that dropdown item.

@nurikabe
Copy link

+1

4 similar comments
@raulromanp
Copy link

+1

@danielfariati
Copy link

+1

@deepugn
Copy link

deepugn commented Dec 17, 2014

+1

@iainvdw
Copy link

iainvdw commented Aug 3, 2015

+1

@klzns
Copy link

klzns commented Sep 2, 2015

If anyone is wondering how to change it as @brianreavis suggested, just do something like this:

$('.my-select').selectize({
  create: true,
  render: {
    option_create: function(data, escape) {
      var addString = 'Adicionar';
      return '<div class="create">' + addString + ' <strong>' + escape(data.input) + '</strong>&hellip;</div>';
    }
  }
});

@joallard
Copy link
Member

joallard commented Jan 3, 2016

As someone who's native tongue is French, I'd be inclined to accept a PR making this simpler. We could add an option allowing you to spectify a string (eg. addString: "Add %{name}") or a function addString: function(word){ I18n.t("selectize.add", word)}.

sg00dwin pushed a commit to sg00dwin/selectize.js that referenced this issue Jan 11, 2016
Handle case where setLabelSelector gets called before filter widget i…
@Oxicode
Copy link

Oxicode commented May 4, 2016

+1

@joallard
Copy link
Member

joallard commented May 4, 2016

I'll go even further in this, the function would be called with two params, function(word, key), allowing one to do:

addString: I18n.t

instead of:

addString: function(word, key){ I18n.t(word, key) }

Default: I18n.t if exists (or whatever is the JS convention for translation), or "Add %{name}".

or something automagic like that.

@joallard
Copy link
Member

joallard commented May 9, 2016

  • Figure out strings that can be translated
  • Figure out I18n conventions in JS and sensible defaults
  • Begin writing tests
  • Finish writing tests
  • Write the code

@joallard
Copy link
Member

joallard commented May 9, 2016

Here's what I see:

describe("I18n", function(){
    describe("dictionary syntax", function(){
        var s = Selectize.init({
            dictionary: {
                addThis: "Ajouter %{elem}"
            }
        })

        expect(s.i18n('addThis', {elem: 'ceci'}).to.equal("Ajouter ceci")
    })

    describe("delegate to i18n library", function(){
        var I18n = {
            t: function(key, params) {
                return "Ajouter " + params.elem;
            }
        }

        var s = Selectize.init({
            i18n: I18n.t
        });

        expect(s.i18n('addThis', {elem: 'ceci'})).to.equal("Ajouter ceci")
    })

    describe("default i18n library", function(){
        var I18n = {
            t: function(key, params) {
                return "Ajouter " + params.elem;
            }
        }

        var s = Selectize.init({
            // i18n: default
        });

        expect(s.i18n('addThis', {elem: 'ceci'})).to.equal("Ajouter ceci")
    })
})

@joallard
Copy link
Member

Libraries i18next, I18n-js and Polyglot all use syntax .t()

@risadams
Copy link
Contributor

closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.

@pixelbart
Copy link

pixelbart commented Jun 20, 2022

Is it possible to translate things meanwhile?

For example, remove-single has "remove" in the title. This would have to be translated for my use case.

image

@joallard
Copy link
Member

It's been a while I haven't touched this project, but I would imagine a PR that makes it possible to specify the language string in the options would be a great start.

Oops, actually that's what #902 proposed and I closed the PR in favor of this one. (harsh.) Funny how I don't agree with my past self anymore, I think something along the lines of #902 is a good idea, maybe a bit more fleshed out. But again, I'm not the one who puts much work in this project anymore so that's only my own personal opinion!

@risadams
Copy link
Contributor

always welcome a PR, my time is stretched these days too, and I fully admit that my i18n skills are underdeveloped. I agree that #902 at least feels more simple to implement, but I would need to do some research before jumping in myself

@risadams risadams reopened this Jun 30, 2022
@risadams risadams added the pending review This issue was closed as stale; since then additional review has been requested. label Jun 30, 2022
@gotivac
Copy link

gotivac commented Oct 26, 2024

Huh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pending review This issue was closed as stale; since then additional review has been requested. pull request welcome
Projects
None yet
Development

No branches or pull requests