You are not logged in.
- Topics: Active | Unanswered
#1 2009-07-20 16:43:17
- zaher
- Member

- From: Damascus, Syria
- Registered: 2008-07-12
- Posts: 118
- Website
Change languages to none PHP files.
Languages is written in PHP file, can be read by programmers likes me, in the past (with PunBB) i made translator hardly parse this files and give gui application to make easy translation.
The fact my translator has bugs when reading php files and it hard for me to maintain that structure.
If can make in next version of FluxBB the languages be in plain files or xml files (i prefer the first one) or in PO file then use it or convert it in into cache folder, or use it as is.
That can make it more easy to put parser for it, if you choose PO file i can write php parser for it that can convert PO file to php cache file, then you will find many editor for PO file on the internet.
Thanks.
Offline
#2 2009-07-20 16:59:31
- Reines
- Lead developer

- From: Scotland
- Registered: 2008-05-11
- Posts: 3,140
- Website
Re: Change languages to none PHP files.
Depending on the caching options that may actually be something worth considering for FluxBB 2.0.
Offline
#3 2009-07-20 17:06:21
Offline
#4 2009-07-20 17:26:08
- zaher
- Member

- From: Damascus, Syria
- Registered: 2008-07-12
- Posts: 118
- Website
Re: Change languages to none PHP files.
>Hard to do translation in a PHP file
Yes
and hard to parse PHP files in my GUI application.
Why use GUI application?
It is more easy to review, check and find missed words etc...
Ah, also it is hard to write in right to left language (Arabic, Hebrew) especially if mixed with English words in php source files.
Last edited by zaher (2009-07-20 17:26:39)
Offline
#5 2009-07-20 17:27:36
- Franz
- Lead developer

- From: Germany
- Registered: 2008-05-13
- Posts: 3,755
- Website
Offline
#6 2009-07-20 17:44:33
- zaher
- Member

- From: Damascus, Syria
- Registered: 2008-07-12
- Posts: 118
- Website
Re: Change languages to none PHP files.
>It would be even easier to write a PHP application
Hmm, i have already translator GUI application, and may be another one can write a PHP application.
Offline
#7 2009-07-20 17:44:38
- FSX
- Developer

- From: NL
- Registered: 2008-05-09
- Posts: 803
- Website
Re: Change languages to none PHP files.
Well, it should not be a problem to write a GUI application for translation...
It would be even easier to write a PHP application...
I think it isn't really easy to parse the PHP language files when you write an application with an other languague than PHP
Offline
#8 2009-07-20 17:48:07
- zaher
- Member

- From: Damascus, Syria
- Registered: 2008-07-12
- Posts: 118
- Website
Re: Change languages to none PHP files.
Not just parse, right to left language it is hard to write it inside source editor or even notepad mixed with source code.
Last edited by zaher (2009-07-20 17:51:07)
Offline
#9 2009-07-20 18:26:21
- MattF
- Member

- From: South Yorkshire, England
- Registered: 2008-05-06
- Posts: 1,230
- Website
Re: Change languages to none PHP files.
In what way would it be any easier in a different format? Any scripting language should be able to parse any type of text file practically without blinking.
Screw the chavs and God save the Queen!
Offline
#10 2009-07-20 20:37:46
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,117
- Website
Re: Change languages to none PHP files.
There are some more widely accepted standards for language files: http://framework.zend.com/manual/en/zen … r.decision
It would be possible to use one of those directly: alternately, you could have a piece of software to generate the proper array from one of those files.
Offline
#11 2009-07-20 21:52:26
- Franz
- Lead developer

- From: Germany
- Registered: 2008-05-13
- Posts: 3,755
- Website
Re: Change languages to none PHP files.
Am I getting this correctly?
There would be language entries in, say, an INI file? But the actual language entries used when running the software would be the typical PHP files that are simply generated from the INI files? So this would only be a small advantage for language editors, right?
Offline
#12 2009-07-20 22:31:42
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,117
- Website
Re: Change languages to none PHP files.
Well, I was thinking more along the lines of gettext:
http://us.php.net/_
Like I said, it could be used directly by using _() or someone could write a tool to turn those files into files in the current format. Either way, it provides a more convenient format for language pack authors.
Offline
#13 2009-07-21 12:01:41
- MattF
- Member

- From: South Yorkshire, England
- Registered: 2008-05-06
- Posts: 1,230
- Website
Re: Change languages to none PHP files.
What benefit would a different format give though? That's the part which I can't see at the moment. Other than just having a different file format, where is the actual benefit of that format? I'm obviously completely missing the point somewhere along the line. ![]()
Screw the chavs and God save the Queen!
Offline
#14 2009-07-21 12:12:16
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,117
- Website
Re: Change languages to none PHP files.
The file format is more widely used for internationalization purposes: it's designed to be used for internationalization. There are tools for it, etc.
Offline
#15 2009-07-21 13:30:18
- Reines
- Lead developer

- From: Scotland
- Registered: 2008-05-11
- Posts: 3,140
- Website
Re: Change languages to none PHP files.
Here's a quick read for anyone interested in advantages of using gettext over the current method: http://mel.melaxis.com/devblog/2005/08/ … g-gettext/. The main disadvantage obviously being it either requires a PHP extension or a 3rd party library (or more coding on our behalf), my feeling is we would probably want to write our own implementation if something like this was to be implemented.
Offline
#16 2009-07-21 17:07:07
- Franz
- Lead developer

- From: Germany
- Registered: 2008-05-13
- Posts: 3,755
- Website
Re: Change languages to none PHP files.
What about performance if using gettext()? Because if there is a loss, the files should be cached to something like what is used now.
EDIT: Ignore the performance question. I should have read the articles you posted earlier, Smartys:
http://mel.melaxis.com/devblog/2006/04/ … st-enough/
Last edited by Franz (2009-07-21 17:23:06)
Offline
#17 2009-07-21 20:39:28
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,117
- Website
Re: Change languages to none PHP files.
Reines: We can check out Wordpress, they use gettext (with, I assume, a pure PHP backup in case the extension isn't loaded).
Offline
#18 2009-07-21 21:08:56
- Reines
- Lead developer

- From: Scotland
- Registered: 2008-05-11
- Posts: 3,140
- Website
Re: Change languages to none PHP files.
From what I can see Wordpress uses a pure PHP solution and not the extension at all. I would imagine given a good caching system a pure PHP solution isn't going to damage performance significantly, but it may be worth trying to do some benchmarks?
I wonder if using the extension and falling back to a PHP solution when not available is best, or if there is a reason that Wordpress specifically doesn't use the extension?
PS. The extension seems to cache the dictionary in memory on a per-process basis.
Edit: I'm having trouble trying to test using the PHP extension, setlocale seems to only be willing to use locales installed on the OS and not ones provided within a subdir of the script. If this is the way it's meant to act it's pretty much useless except on a dedicated server or VPS. A pure PHP solution seems to load a whole dictionary and output a test translation in ~7ms (on my server, P4 3.0ghz), or ~0.4-0.6ms when caching the dictionary using XCache and ~0.5-0.8ms using file caching.
Last edited by Reines (2009-07-22 01:03:33)
Offline
#19 2009-07-22 01:40:36
- Smartys
- Former Developer
- Registered: 2008-04-27
- Posts: 3,117
- Website
Re: Change languages to none PHP files.
The setlocate restriction is the reason Wordpress uses a pure PHP implementation ![]()
Offline
#20 2009-07-22 12:38:02
- zaher
- Member

- From: Damascus, Syria
- Registered: 2008-07-12
- Posts: 118
- Website
Re: Change languages to none PHP files.
There would be language entries in, say, an INI file? But the actual language entries used when running the software would be the typical PHP files that are simply generated from the INI files? So this would only be a small advantage for language editors, right?
Yes.
Someone could write a tool to turn those files into files in the current format.
For PO I can make that tools in php i already have one in Pascal and i can port it to PHP.
What benefit would a different format give though? That's the part which I can't see at the moment. Other than just having a different file format, where is the actual benefit of that format? I'm obviously completely missing the point somewhere along the line
In the past i give the languages files to my sister to make the initial translation because she is a moderator in some Arabic forums, but she make the translations after damage the source of php, for that i forced to make the gui application.
In this days i will make the translation and may be give it to my wife
.
I like to make cache file for languages instead of use any structure directory for speed propose.
Last edited by zaher (2009-07-22 12:42:51)
Offline
#21 2009-07-22 13:12:21
- elbekko
- Former Developer

- From: Leuven, Belgium
- Registered: 2008-04-30
- Posts: 1,131
- Website
Re: Change languages to none PHP files.
I don't see what's so hard about parsing the language files
A very simple regex should be able to handle that (#$(.+?) \= "(.+?)"# or something).
Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks
Offline
#22 2009-07-22 13:30:40
- zaher
- Member

- From: Damascus, Syria
- Registered: 2008-07-12
- Posts: 118
- Website
Re: Change languages to none PHP files.
Parsing PHP for read languages words only is different from parsing PHP files for read and modify it then rewrite the languages files as like as be before load it.
Offline
#23 2009-07-22 16:58:52
- MattF
- Member

- From: South Yorkshire, England
- Registered: 2008-05-06
- Posts: 1,230
- Website
Re: Change languages to none PHP files.
Parsing PHP for read languages words only is different from parsing PHP files for read and modify it then rewrite the languages files as like as be before load it.
Yup, but that code Elbecko posted would give you the keys and values which could easily be input into any editor and placed together correctly again on save. Why not just write your UI to deal with the existing format? It's hardly a stretch. A web UI could be created in practically no time for editing the lang files, as they are now. I still can't see the point of changing the format, personally.
Last edited by MattF (2009-07-22 16:59:29)
Screw the chavs and God save the Queen!
Offline
#24 2009-07-22 17:06:08
- Reines
- Lead developer

- From: Scotland
- Registered: 2008-05-11
- Posts: 3,140
- Website
Re: Change languages to none PHP files.
Well if there is a standard format for language files (po/mo) it would seem nice to make use of it. Storing a dictionary within PHP files doesn't seem the "best" solution. Saying that though there is no point in using a different format if it affects performance.
Offline
#25 2009-07-22 17:41:25
- MattF
- Member

- From: South Yorkshire, England
- Registered: 2008-05-06
- Posts: 1,230
- Website
Re: Change languages to none PHP files.
Best and commonly accepted ne'er need go hand in hand. The common solution isn't always the best solution. Having to create a specific wrapper/library just to use the thing hardly seems to keep with the lean and mean principle, btw.
Screw the chavs and God save the Queen!
Offline
