Skip to content
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

Sort on i18n.fa field #29

Open
hrhitesh opened this issue Apr 27, 2016 · 1 comment
Open

Sort on i18n.fa field #29

hrhitesh opened this issue Apr 27, 2016 · 1 comment

Comments

@hrhitesh
Copy link

hrhitesh commented Apr 27, 2016

Hello all,

I have an issue with sorting on i18n.fa field.
here is my collection format
name:"a" "i18n" : { "fa" : { "name" : "fs" } }, name:"c" "i18n" : { "fa" : { "name" : "fa" } }, name:"b" "i18n" : { "fa" : { "name" : "fc" } }

now in my code i used this publication code
TAPi18n.publish("name", function () { return Names.i18nFind({}),{sort:{name:1}}); });
and in client side i use this subscriptions
TAPi18n.subscribe('name', function() { return Names.i18nFind({}); });

now when i run application it gives alphabetical order "a,b,c" in english language. But when i switch language to "fa" it does not gives order "like fa,fa,fs" instead it gives "fs,fc,fa". Does anyone have solution for this why its not working?
Thanks

@timbrandin
Copy link

timbrandin commented May 6, 2016

Right now, this is a bug, the quick fix is to hack it and sort by language yourself.

    let lang = TAPi18n.getLanguage();
    // Adding language specific sorting.
    let sorting = lang == 'en' ? { name: 1 } : {
      [`i18n.${lang}.name`]: 1
    };
    return Names.find({
      category: instance.category.get()
    }, {
      sort: sorting
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants