Reply
Languages and templates
Old 06-16-2008, 08:06 PM Languages and templates
Banned

Posts: 32
I was thinking about the best way to combine templates and language files.
Shall i keep the text/sentences/expressions inside each template or keep it separate?

- If i keep the template with the text i need to set 1 template version for each language (if you change tamplate A structure for 1 language you need to change it to all the other languages).
PHP Code:
[english]
$template '<div>
<span class="little">This is Text</span>
</div>'
;
[
spanish]
 
$template '<div>
 <span class="little">Esto eres texto</span>
 </div>'
;
..
.. 
- If i keep it separate its more efficient yet its very user unfriendly because people will see only references to the texts and it might become confusing.
PHP Code:
$template '<div>
<span class="little">'
.$text['342'].'</span>
</div>'

A dilemma

Last edited by Elenis : 06-16-2008 at 08:12 PM.
Elenis is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-17-2008, 04:37 AM Re: Languages and templates
rogem002's Avatar
Webmaster Talker

Posts: 652
Name: Mike
Location: United Kingdom
You could just place all the words for each language in an array and make the user say what language they want. For example:
PHP Code:
$lang[english][hello] = "Hello";
$lang[french][hello] = "bonjour";
$lang[spanish][hello] = "hola";

// User defines what language
$language "english";

// Say hello
echo $lang[$language][hello]; 
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
Fix 90% of your internet problems
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 06-17-2008, 04:53 AM Re: Languages and templates
Banned

Posts: 32
Whats the difference from your post and my 2nd example? o_o
Elenis is offline
Reply With Quote
View Public Profile
 
Old 06-17-2008, 04:59 AM Re: Languages and templates
rogem002's Avatar
Webmaster Talker

Posts: 652
Name: Mike
Location: United Kingdom
Mine uses an deep array, your uses numbers :P

*[sarcasm] Blatantly did not just guess the answer to your post *
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
Fix 90% of your internet problems
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 06-17-2008, 09:46 AM Re: Languages and templates
Banned

Posts: 32
Lol, i would i want to write a text code for thousands of language lines? a number is way easier...

anyways, guess i will have to compromise friendliness to achieve efficiency.

Last edited by Elenis : 06-17-2008 at 09:48 AM.
Elenis is offline
Reply With Quote
View Public Profile
 
Old 06-17-2008, 01:59 PM Re: Languages and templates
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 995
Name: Jeremy Miller
Location: Reno, NV
I have a couple of principles for supporting multiple languages:

1) Load only what's necessary, and
2) Reference using the language code (see http://www.w3.org/TR/REC-html40/stru...g.html#h-8.1.1 ). For example, "en", "fr", "es"

That said, it is generally not necessary to load a translation for every language -- most of the time the primary language of the site visitor suffices. To accomplish this, a modification of the multidimensional array above suffices:

Filename: en.php
PHP Code:
$lang['hello'] = 'Hello'
Filename: fr.php
PHP Code:
$lang['hello'] = 'Bonjour'
Filename: es.php
PHP Code:
$lang['hello'] = 'Hola'
PHP Code:
// User defines what language
$language "en";

require_once(
$language.'.php');
// Say hello
echo $lang['hello']; 
In my sites, I generally have multiple pages, so I create a core language file (as shown above) which includes text which shows up on more than 1 page and then a language file for each page which includes the text for that page which is not in the core file. This minimizes the amount of memory necessary to create each page.
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-17-2008, 02:01 PM Re: Languages and templates
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Text codes already exist... http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-17-2008, 07:38 PM Re: Languages and templates
Banned

Posts: 32
You didnt follow my topic: combination of languages and templates..you only refer to languages...

Quote:
Originally Posted by JeremyMiller View Post
I have a couple of principles for supporting multiple languages:

1) Load only what's necessary, and
2) Reference using the language code (see http://www.w3.org/TR/REC-html40/stru...g.html#h-8.1.1 ). For example, "en", "fr", "es"

That said, it is generally not necessary to load a translation for every language -- most of the time the primary language of the site visitor suffices. To accomplish this, a modification of the multidimensional array above suffices:

Filename: en.php
PHP Code:
$lang['hello'] = 'Hello'
Filename: fr.php
PHP Code:
$lang['hello'] = 'Bonjour'
Filename: es.php
PHP Code:
$lang['hello'] = 'Hola'
PHP Code:
// User defines what language
$language "en";

require_once(
$language.'.php');
// Say hello
echo $lang['hello']; 
In my sites, I generally have multiple pages, so I create a core language file (as shown above) which includes text which shows up on more than 1 page and then a language file for each page which includes the text for that page which is not in the core file. This minimizes the amount of memory necessary to create each page.
Elenis is offline
Reply With Quote
View Public Profile
 
Old 06-17-2008, 08:19 PM Re: Languages and templates
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 995
Name: Jeremy Miller
Location: Reno, NV
Well, what do you want to do with a template? I usually create 1 file and include the language stuff in there -- this code
PHP Code:
// User defines what language
$language "en";

require_once(
$language.'.php');
// Say hello
echo $lang['hello']; 
</span></span>
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Languages and templates
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15380 seconds with 12 queries