TAPevents / tap-i18n-db

MIT License
51 stars 17 forks source link

Existing collections and tap-i18n-db #15

Closed benderskiy closed 9 years ago

benderskiy commented 9 years ago

Hello,

I have a Meteor application with some collections I want to translate now, I've added both i18n and i18n-db plugins, then I've made the following changes:

... (server)
PortfolioCategory = new TAPi18n.Collection('PortfolioCategory', {base_language : "en"});
...
TAPi18n.publish("PortfolioCategory", function() {
    return PortfolioCategory.i18nFind();
});
... (client)
TAPi18n.subscribe("PortfolioCategory");

instead of

... (server)
PortfolioCategory = new Meteor.Collection('PortfolioCategory');
...
Meteor.publish("PortfolioCategory", function() {
    return PortfolioCategory.find();
});
... (client)
Meteor.subscribe("PortfolioCategory");

In my application the collection seems to be empty afterwards

PortfolioCategory.find().fetch()
[]

Meteor console has a following error:

I20150730-21:29:37.024(2)? Exception from sub PortfolioCategory id dhisMMMEttj2c
qzSk TypeError: Array.prototype.indexOf called on null or undefined
I20150730-21:29:37.025(2)?     at [object Object].obj.i18nFind (packages/tap:i18
n-db/tap_i18n_db-server.coffee:17:35)
I20150730-21:29:37.025(2)?     at [object Object].<anonymous> (app\collections\c
ollections.js:8:31)
I20150730-21:29:37.025(2)?     at [object Object].i18n_handler (packages/tap:i18
n-db/tap_i18n_db-server.coffee:79:23)
I20150730-21:29:37.025(2)?     at [object Object]._.extend.withValue (packages/m
eteor/dynamics_nodejs.js:56:1)
I20150730-21:29:37.025(2)?     at packages/matb33:collection-hooks/collection-ho
oks.js:218:1
I20150730-21:29:37.025(2)?     at maybeAuditArgumentChecks (packages/ddp/livedat
a_server.js:1617:1)
I20150730-21:29:37.025(2)?     at [object Object]._handler (packages/matb33:coll
ection-hooks/collection-hooks.js:217:1)
I20150730-21:29:37.025(2)?     at [object Object]._.extend._startSubscription (p
ackages/ddp/livedata_server.js:769:1)
I20150730-21:29:37.025(2)?     at [object Object]._.extend._runHandler (packages
/ddp/livedata_server.js:950:1)
I20150730-21:29:37.025(2)?     at indexOf (native)

app\collections\collections.js:8:

6: if (Meteor.isServer) {
7:  TAPi18n.publish("PortfolioCategory", function() {
8:      return PortfolioCategory.i18nFind();
9:  });

Any feedback will be appreciated!

Regards

theosp commented 9 years ago

Comes from these lines: https://github.com/TAPevents/tap-i18n-db/blob/master/tap_i18n_db-server.coffee#L17-L18

Make sure you followed Step 6 of the Getting Started: https://github.com/TAPevents/tap-i18n-db#getting-started

-Daniel Meteor Developer

benderskiy commented 9 years ago

@theosp thanks for a quick response!

If you already use tap-i18n to internationalize your UI, you are done!

I've understood it so that, meteor add tap-i18n is enough, but without project-tap.i18n it doesn't work either.

Anyway, fixed it now, thank you for your help!