database design - PHP web app internationalization -
i building php web app requires internationalization. have decided use get-text system related strings , perhaps database tables user generated content.
for example, user might able post blog post. should able post different versions of post in different languages. can implement storing posts in posts table column denoting language.
the difficult bit trying internationalize system strings stored in database.
for example, have table stores privileges. each privilege should have string describes privilege does.
at moment, stored in table this:
app_privileges
- id
- privilege
- some other columns
- description
i plan use application poedit generate gettext files. able search through php files grab strings. in cases string stored in database, can fair bit of work extract string transation. tricks , solutions handling this?
finally, lets have data types , forms users can create , define in app. example, defining "product type" shopping cart. means product have own unique set of attributes , descriptions. these attributes require translating along description.
the same case forms. user can create form might stored in set of tables. these forms need translated.
what database models can use store translations forms , product types?
cheers :)
for strings more "system"-oriented, :
- buttons
- feature names
- privileges
- etc
gettext good.
privileges, instance, more "system"-oriented (users don't create privileges, rather admins grant them users don't create new types of privileges). so, privileges table can have column "privilege_name" never displayed , contains gettext keys, instance : "privilege : user can edit posts in specified forum".
strings in application should not text user see, more detailed "menu: edit preferences".
those strings go through gettext (even english or site's "mother tongue") , translated proper user-visible strings.
you should use numbered sprintf-style arguments, ie not "price of %s %s" "price of %(1)s %(2)s".
this has several advantages :
- gettext provides little context, , merges identical strings. translator sees "button: edit post" have lot more translator sees "edit". in languages, simple text "edit" may translate different words, or grammatical forms of same verb, depending on "edited".
- you can change english text @ without breaking gettext keys other languages
- numbered arguments handle languages different ordering of subject/verb/etc
if have text in images (like buttons) need take care of too. gettext can translate filenames, (images/buttons/en/submit.png => images/buttons/fr/valider.png although simple regexp nice too) , don't forget blind people using screen readers.
for multilingual user-generated content (stored in tables), usual relational approach better.
table posts( post_id ... ) table posts_translated( post_id foreign key, language_id foreign key, title, text, etc )
this allow use sql showing list of languages available post, allowing default languages, showing untranslated posts, fulltext search, etc.
Comments
Post a Comment