DooPHP IRC channel


Best way with language files

This is for general web development discussions that are not related with DooPHP.
PHP, Flash, HTML, Javascript, Useful tools, etc.

Best way with language files

Postby Mil0s » Mon Feb 08, 2010 6:54 pm

What do you prefer for translation store all translations in files or keep them in DB and then store them in APC?
Keep it fast and keep it simple!
DooPhp
Mil0s
 
Posts: 221
Joined: Mon Aug 31, 2009 2:15 pm
Location: Serbia

Re: Best way with language files

Postby RichardM » Mon Feb 08, 2010 8:11 pm

Hey Mil0s,

The file based option has been quite useful recently in terms of quick and easy to make changes...no need to go intergrating to much into admin part of site to manage them.

I think my issues are less with how the system stores the translations but rather how the translations are managed. Some things I would like to see include:
Support to easily add new languages. In actual fact this is very easy right now. I just create a 'languageCode.lang' (ie. en.lang, fr.lang) file in a language folder any the base controller auto selects which to use

Some way of identifying which indexes have not been translated. For example right now I have every string identfied something like 'page-home-page_title' or 'common-string-login' etc...this is all fine and works nicely BUT if I add another page and write the english version I do not nessecarily know I need to go in and update the other languages so they have the correct strings. Additionally as I don't speak any other languages I am not the one who deal with the other translations.

I would like it if there was someway for the system to track what index's have not been translated so either append the missing index's to the bottom of the language file OR in the case of the DB option let me identify what keys where missing. This way its more obvious to another user that they need to translate the string

I would also like to have support for a Fall Back language so if I have not yet translated some string from engligh to russian or french they would default to the translation in my english (default) language file so instead of seeing the index like 'page-home-page_title' they would see the english page title.

Another one which I had not thought about much until yesterday is that the translation system works well when you have (semi) static strings but it would be nice if it could be extended some how to support content management systems. For example I might write a blog post in english but like to have the option to write it in another language(s). Then it would load and display the approprtiate version.

Also given I do not speak another language it would be nice if it could be setup to use a third party translation service (say google) to translate the text of my blog post from english to say french and then cache the translated version locally so it does not have to look it up on every subsequent page request. So it would give you a cross between a default string and writing a proper translation.

Sorry its gone a bit off topic from your initial post. I think using the DB would probably be a nice addition but possibly with it continuing to use the default file options too? Also if using a DB it might be nice if you could extract the translations and cache them by some sort of tag. For example I have used the ability to use the {{+ ...}} feature of DooView(Basic) so I do not have to have static strings translated on each page request. They just get translated at when they are compiled. So I would not need to have these strings pulled out of the DB all the time. Not really sure of the best way for this to work but in my head I would see it being a cross between pulling out a whole language's translations (I have about 2,000 strings in mine atm) or pulling them out 1 at a time...which could mean 150+ db requests.


Richard
PS: Does this mean your exams are out of the way now for a while?
Note: code samples my not be 100% accurate.
RichardM
 
Posts: 1329
Joined: Sun Aug 30, 2009 6:03 pm
Location: Cumbria, UK

Re: Best way with language files

Postby Mil0s » Mon Feb 08, 2010 9:33 pm

Yeah dont have exams anymore I will dedicate my work more on programming, tnx for your long comment on it, notice about untranslated text is great thing I will add it soon, for DB stuff I just asked what do you prefer in your projects its not going to be some new feature in DooTranslate.
So for untranslated string you want something like:
"home-page-title";"This is homepage title"
Keep it fast and keep it simple!
DooPhp
Mil0s
 
Posts: 221
Joined: Mon Aug 31, 2009 2:15 pm
Location: Serbia

Re: Best way with language files

Postby RichardM » Mon Feb 08, 2010 9:47 pm

Good to hear the exams are out of the way. Hope they all went okay.

I think it should be easy enough for people to port DooTranslate to use a DB without needing a dedicated module. Or if one is needed it should not define to much in terms of the db structure etc. I could forsee it being easier to build an admin feature from.

With regards to undefined strings I was thinking something like
en.lang
Code: Select all
common-string-one|"One"
common-string-two|"Two"
common-string-three|"Three"


fr.lang
Code: Select all
common-string-one|"Un"

Note: In the french language file common-string-two and common-string-three are undefined.

Now if I was to use the translator class to fetch common-string-two in french I would like it to do the following
1) Some how report that its missing. I was thinking maybe it can add the following to the bottom of the language file:
Code: Select all
common-string-two|__UNDEFINED__

2) It would load the english translation from the english translation file (as english is my apps default language)

I suggest the __UNDEFINED__ as it makes or more obvious to the person translating strings AND the translator class that this string is undefined and to revert to the default string.


Richard
Note: code samples my not be 100% accurate.
RichardM
 
Posts: 1329
Joined: Sun Aug 30, 2009 6:03 pm
Location: Cumbria, UK

Re: Best way with language files

Postby Bint » Sat Mar 13, 2010 9:09 pm

Hi!

Im requesting the same: the ability to "default" to English if some strings wont get translated for some id's.

About storing translation strings @ DB or Filesystem:

My concern is about performance and how that will work.
RichardM pulls a good question: while using DB, will i get some sort of caching mechanism, as for first load gets the heavy hit (only once)? Or its going to pull it from DB string by string? That's a lot of DB hits...

Same goes for using filesystem: will it read once and cache it, or will read it string by string needed?
Thanxs!

Bint
Bint
 
Posts: 7
Joined: Fri Feb 05, 2010 11:39 am

Re: Best way with language files

Postby Mil0s » Thu Mar 18, 2010 4:23 pm

Translator class caches translation.
Keep it fast and keep it simple!
DooPhp
Mil0s
 
Posts: 221
Joined: Mon Aug 31, 2009 2:15 pm
Location: Serbia

Re: Best way with language files

Postby saim786 » Mon Dec 03, 2012 6:01 am

hello admin nice forum . i am a new user and i will be actively participating .. :cool:
Saim...:)
saim786
 
Posts: 1
Joined: Mon Dec 03, 2012 5:57 am


Return to General Web Development Topics

Who is online

Users browsing this forum: No registered users and 2 guests

cron