Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

best way to build a multi-language site with smarty
Goto page Previous  1, 2, 3, 4, 5 ... 13, 14, 15  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Wed May 14, 2003 10:07 pm    Post subject: Reply with quote

But bablefish translations are laughable at best, handmade translations are still the best.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
toma
Smarty Regular


Joined: 25 Apr 2003
Posts: 62

PostPosted: Thu May 15, 2003 4:00 pm    Post subject: Reply with quote

I completly agree, however, I think they provide a good start. You certainly don't need to use whatever it comes up with.

The main benefit of my multilanguage stuff isn't the babelfish, it's the fact that it uses gettext through a smarty plugin.
Back to top
View user's profile Send private message Visit poster's website
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Thu May 15, 2003 7:05 pm    Post subject: Reply with quote

Well I wrote the XML way because I had hard times getting gettext to be portable so I wrote a portable solution based on gettext.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
toma
Smarty Regular


Joined: 25 Apr 2003
Posts: 62

PostPosted: Thu May 15, 2003 7:10 pm    Post subject: Reply with quote

Just curious, what problems did you run into with gettext? It went pretty smoothly for me. Running on linux was no problem and running on windows simply involved copying a couple dlls (not documented correctly in the manual unfortunatly) to a path searchable directory then uncommenting the extension=php_gettext.dll

I did have cygwin installed with gettext so the msgfmt executable was already on my machine. I think this binary would be the biggest obstacle to using gettext since you must compile your .po (translation) files. My understanding is gettext uses compiled files instead of the flat .po files for efficiency and speed.
Back to top
View user's profile Send private message Visit poster's website
Budda
Smarty Regular


Joined: 19 Apr 2003
Posts: 53
Location: Lymm, Cheshire. UK

PostPosted: Fri May 16, 2003 9:12 am    Post subject: Re: each config file for each language Reply with quote

smartymoon wrote:
you may create config files for each lang
like
lang.eng,config
lang.spn.config


and assign $LANG and use in template to fetch file

{config_load file="lang.$LANG.conf"}

I've done something like this. However I made seperate directories for each supported language.
Then in each directory i put standard named files in, each one representing a single page to keep loading overhead down on page pharsing.
At the top of each smarty template i then just load the config file in without bothering to consider what language i'm using.
.
Code:
{config_load file="myprofile.editprofile.lang" scope="local"}

The language setting is changed by simply re-directing where the Smarty class loads its config files from - just change the path in your extended Smarty class on creation Very Happy
Code:
$smarty->config_dir = $g_ps['Core']['baseDirectory']."Var/locale/{$g_ps['Core']['language']}/";

I think it's the cleanest and fastest method.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Fri May 16, 2003 10:29 am    Post subject: Reply with quote

toma wrote:
Just curious, what problems did you run into with gettext? It went pretty smoothly for me. Running on linux was no problem and running on windows simply involved copying a couple dlls (not documented correctly in the manual unfortunatly) to a path searchable directory then uncommenting the extension=php_gettext.dll

I did have cygwin installed with gettext so the msgfmt executable was already on my machine. I think this binary would be the biggest obstacle to using gettext since you must compile your .po (translation) files. My understanding is gettext uses compiled files instead of the flat .po files for efficiency and speed.


I had noi problem up until porting it to freebsd then it got tricky. PHP just didnt like it.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
toma
Smarty Regular


Joined: 25 Apr 2003
Posts: 62

PostPosted: Fri May 16, 2003 3:52 pm    Post subject: Re: each config file for each language Reply with quote

Budda wrote:
smartymoon wrote:
you may create config files for each lang
like
lang.eng,config
lang.spn.config


and assign $LANG and use in template to fetch file

{config_load file="lang.$LANG.conf"}

I've done something like this. However I made seperate directories for each supported language.
Then in each directory i put standard named files in, each one representing a single page to keep loading overhead down on page pharsing.
At the top of each smarty template i then just load the config file in without bothering to consider what language i'm using.
.
Code:
{config_load file="myprofile.editprofile.lang" scope="local"}

The language setting is changed by simply re-directing where the Smarty class loads its config files from - just change the path in your extended Smarty class on creation Very Happy
Code:
$smarty->config_dir = $g_ps['Core']['baseDirectory']."Var/locale/{$g_ps['Core']['language']}/";

I think it's the cleanest and fastest method.


By using this method you have to remember what magic word you assigned to each phrase, correct?

{#intro#} may be one, for instance. Using gettext you can edit the template naturally. My plugin uses {t}Hi, wecome to this website{/t}. This method should be many times easier to maintain, especially for a developer who did not originally code the site.

Imagine this: I want to use a gpl'd app that uses config loading type files but I don't care about multilanguage stuff. The ideal method for me to use this gpl'd app would be to remove all {#intro#} type tags and replace them with the static text which the config method inserts there. This would be a very time consuming process and, until it's done, I would not be able to edit any template directly. I would need to edit every template while referencing the translation file at the same time.

Using block.t you would just edit the function to return the string passed to it without doing any translations. The string will already be in the template files untranlated and unaliased.

I hope I'm explaining all this well. gettext is the ideal method for translating strings in php because it's a module, it uses compiled translation files for speed, and you don't need to add a bunch of tokens into your web pages...you can edit them naturally instead. I think most developers don't use it because they don't know about it or they don't understand it's advantages.
Back to top
View user's profile Send private message Visit poster's website
toma
Smarty Regular


Joined: 25 Apr 2003
Posts: 62

PostPosted: Mon May 19, 2003 4:51 pm    Post subject: Reply with quote

andreas wrote:
toma wrote:
The script at the above link uses the babelfish for translations to help you get started.

is this allowed?


I've edited the block.t plugin and added a 'use_babelfish' variable. If set to false then babelfish will not be used to generate translations.

Also, I added a new global array which lists all supported languages for your site. By populating this with the languages you wish to support, when in development mode block.t will translate (or place string markers in the .po file) any found string into all supported languages at the same time. (You had to keep changing t_language and rebrowsing your whole site before.)

Tom
Back to top
View user's profile Send private message Visit poster's website
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Tue May 20, 2003 3:02 pm    Post subject: Reply with quote

From http://www.altavista.com/web/legal/termsofuse:

Quote:
You may use the Services on the Site and the AltaVista Sites for your personal, non-commercial use. You may make a single copy of the individual screens you see when you use the Services, but only for your personal use. You cannot distribute or transfer the copies to others in exchange for money or other consideration. You may not-and agree not to-modify, reformat, copy, display, distribute, transmit, publish, license, create derivative works from, transfer or sell any information, products or services obtained from the Services, except as set forth below. This means that you may not mirror the home page or results pages of the Site or any AltaVista Site on your own Web site or Web page.


They will see in their logs what you do with babelfish.
________
one vaporizer reviews


Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Tue May 20, 2003 3:13 pm    Post subject: Reply with quote

Quote:
You may not-and agree not to-modify, reformat, copy, display, distribute, transmit, publish, license, create derivative works from, transfer or sell any information, products or services obtained from the Services, except as set forth below.

I am no lawyer but I think that right there pretty much says you can't take results from bablefish automaticly and display them.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Tue May 20, 2003 3:37 pm    Post subject: Reply with quote

If your site has no commercial background I think your're right
________
Avancier


Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
toma
Smarty Regular


Joined: 25 Apr 2003
Posts: 62

PostPosted: Tue May 20, 2003 5:13 pm    Post subject: Reply with quote

AZTEK wrote:
Quote:
You may not-and agree not to-modify, reformat, copy, display, distribute, transmit, publish, license, create derivative works from, transfer or sell any information, products or services obtained from the Services, except as set forth below.

I am no lawyer but I think that right there pretty much says you can't take results from bablefish automaticly and display them.


Any site can put whatever they want in their terms of use. That doesn't mean that those terms can be enforced legally. e.g. A company could specify that "by using the Services you agree to send a DNA sample from yourself and all immediate family members, at your cost, to your collection center". Of course, they could not enforce this.

My understanding is screen scraping, which is what the following code does, has not been ruled illegal or legal.
Code:
$url ="http://babelfish.altavista.com/babelfish/tr?lp={$t_language_from}_{$t_language}&intl=1&tt=urltext&doit=done&urltext=" . urlencode($content);
$fp = fopen($url, 'r');
// Find the translated string
//foreach ($babel as $line) {
while ($line = fgets($fp)) {
   if (strstr($line, "lang=$t_language")) {
      $translated = htmlspecialchars(trim(strip_tags($line)));
      break;
   }
}
fclose($fp);
unset($url);


But if you do care enough that you don't want to scrape their site, I've now added the boolean use_babelfish, as mentioned before.

edit: Slashdot: Websites Complaining About Screen-Scraping
Back to top
View user's profile Send private message Visit poster's website
andreas
Smarty Pro


Joined: 22 Apr 2003
Posts: 106

PostPosted: Tue May 20, 2003 6:47 pm    Post subject: Reply with quote

toma wrote:
Any site can put whatever they want in their terms of use. That doesn't mean that those terms can be enforced legally. e.g. A company could specify that "by using the Services you agree to send a DNA sample from yourself and all immediate family members, at your cost, to your collection center". Of course, they could not enforce this.


OK, but you may not go to a shop and take everything you can carry with you. Altavista has a copyright for all data provided on their websites. So they can decide how you may use this. And if they say you may not use the data for any comercial purpose you may not use it for something like that. And if you use a script for your application which uses such a service, you must make sure that it's allowed to do so.

I have no problems with such applications, I only wanted to make clear that something like this could cause problems.

If a lot of people would use your babelfish-script for their own comercial applications, would you say "it's OK"?

________
Mazda RX-2 picture

Last edited by andreas on Fri Feb 04, 2011 9:00 am; edited 2 times in total
Back to top
View user's profile Send private message
toma
Smarty Regular


Joined: 25 Apr 2003
Posts: 62

PostPosted: Tue May 20, 2003 7:05 pm    Post subject: Reply with quote

andreas wrote:

If a lot of people would use your babelfish-script for their own comercial applications, would you say "it's OK"?


Yes, I would.

There MAY only be a problem if they were to then sell the unmodified translation files. Were someone to verify the translation files (as they should) after they were created, I can see no reason why anyone would have any issue with them.

There is no copyright on a language. You can't copyright the fact that en francais, merde means, in english, shit. You can certainly copyright an engine that does translations, however.

Riddle me this: What is the difference between manually creating a .po file using an english to french dictionary and manually creating a .po using an english to french web service and automaticly creating a .po file using an english to french web service?

Did you read the slashdot story I posted in my previous post? This is extremely similar.
Back to top
View user's profile Send private message Visit poster's website
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Tue May 20, 2003 8:32 pm    Post subject: Reply with quote

It all depends on who owns the copyright and what country your in. If you live in ohh say Agintina I doubt you will get exterdited for breaking a copyright owned by compny acting under laws in California. But in all seriousness there is a line you don't cross with written things. IMHO as long as you dont copy someone elses ideas and or written work and try to say its yours your ok (textbook plagurism). The whole astalavista issue is a good example. If I didn't live in the US I wouldn't have any problem using the bablefish translations, but I do, and therefore am bound to US laws on copyright and if they say "Hey this is ours we made it don't copy what it generates" then I have to respect that.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks All times are GMT
Goto page Previous  1, 2, 3, 4, 5 ... 13, 14, 15  Next
Page 4 of 15

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP