symfony - Symfony2 Translatable bundle and safest multilingual approach -


i have developed website personal project in specific language on symfony2. takes long time program because follow safe approaches in developing code, if it's silliest things. plan now, implement directory business website - let's musical instrument companies - on world create account , register business.

what have done, have implemented scratch: security bundle, basic entities business {name, location, phone, email, information, etc.}, businesscategory {name, information etc.} , custom simple relationships between them. user can register account , register business. have implemented translations every word or phrase being shown on website using locale in config.yml , custom translations english , let's chinese or spanish. user can click on link "english" or "spanish" , gets translated selected language , website alias changes website.com/en website.com/es.

my next steps are:

  • i want user able register in english or spanish. right now, there 1 entry business in mysql database , translations exist website text. want user able enter english data , spanish data same fields example "name" of business, address etc. need possibly 2 entries different locale , same business.

  • i want website align label translations existing user's translations. means when choose "spanish" translated in spanish , spanish row business.

  • i want use domains have purchased language if possible: website.com, website.es, website.it etc. enter website.it in address bar of browser , automatically in italian.

my main concerns are:

  • if use translatable bundle, additional row created every business. how connected? mean, x business id 1234 in spanish , same 1 name translated y have id 1235. how symfony2 know these 2 businesses same 1 in different locale ?

  • what happen joined tables? user table linked business table linked group table. if use translatable extension business table only, how affect other ones ?

i admittedly hadn't looked deep 2 years ago when checked out, take answer grain of salt. but:

if use translatable bundle, additional row created every business. how connected?

there several approaches having multilingual data in same database.

the first, easiest, , common, manage subtables. in essence, if have table called company, create , manage table, e.g. company_translations or order, company_id , locale fields, holds translated fields. @ app level, propagate property calls accordingly. occasionally, master table hold translation base locale. 1 big con here joins fetch of needed details. lose benefit of collation rules defined @ sql level.

another toss in same table, while keeping reference of locale using field name, , base locale kind of parent_id. rational here e.g. tags , sectors , whatever else need need translated anyway, might toss in there. it's admittedly less common. big con here that, here too, lose benefit of collation rules defined @ sql level.

yet approach have different sets of tables prefixed locale or living in locale-specific schemas. variation of former without introducing collation-related problems, @ cost of introducing worrying table prefixes or search paths @ app level.

a last option not worry @ all, , create separate sets of tables altogether -- in essence, new app -- each locale. whether they're in separate (and independent) schemas or databases matters little. (fwiw, preferred method; see below.)

if memory serves, doctrine uses first of these approaches base locale in master table -- double check sure testing , looking structure of translated set of tables.

i mean, x business id 1234 in spanish , same 1 name translated y have id 1235. how symfony2 know these 2 businesses same 1 in different locale ?

see above, note should least of worries unless you're building site hispanic population living in -- , then, it's dubious worry imho.

the point have in mind here if you're serving verbatim copy of en_us website es_mx users, you're doing wrong on marketing/comm front: don't communicate 2 populations same way. 1 argument might cater 1 of populations , put other 1 off, e.g. "gringos no son bienvenidas". moreover, you're arguably doing disservice audience if fallback serving unexpected locale when no appropriate translation exists.

what happen joined tables? user table linked business table linked group table. if use translatable extension business table only, how affect other ones ?

see first points. on plus side, doctrine's behavior manage you. on minus side, you're introducing joins using behavior.

the alternative i'd advise use 2 sets of independent tables , configure doctrine grabs data based on session's locale. personal opinion.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -