Open Lukasvo opened 7 years ago
Hi @Lukasvo,
From what I see, it's gonna be a hard thing to do. You would have to create your own Astronomy module that handles i18n. It would be a lot of work. The class schema would be quite complex and all the operations would be hard to do. Depending on what for you want to use Astronomy I would recommend the following solution for that.
name: String,
born: Number,
place_of_birth: { // Object or PlaceOfBirth class
country: String
city: String
}
transform
option:
tap_i18n_collection.i18nFind(selector, {
transform(doc) {
return new YourAstronomyClass(doc);
}
});
astroDoc.validate();
const rawDoc = astroDoc.raw();
// convert rawDoc to some translation data
tap_i18n_collection. updateTranslations(translationData);
It's still a lot of work to do so it's not the best solution but should work. The best one would be creating dedicated Astronomy module for i18n but it would be a lot of work to do and i18n applications are not so common.
Alright, thank you for your quick reply! I think creating a dedicated Astronomy module is a bit overambitious for my programming skills, so I'll try using the described method.
Ok great, let me know if you have any problems with this approach
Hi all
I've experimented somewhat with i18n. The transform function was a good idea, jagi, but I decided to move it to the Collection creation so I could also use Astronomy helpers etc. on the server.
export const Reservations = new TAPi18n.Collection('reservations', {
transform(doc) {
return new Reservation(doc);
}
});
Note that classes using inheritance won't work properly with this approach (they'll be instances of the parent class). A switch case choosing the right constructor based on the doc's typeField is a possible solution.
Hi jagi,
What do you think would be the best approach to translate my application based on Astronomy? Both hard-coded strings and database entries should be translated.
One approach might be to use the tap:i18n package with its db extension. The db structure looks like this:
I've got two questions to implement this with Astronomy:
Any advice would be welcome. Thanks in advance!
Cheers! Lukas