Welcome to Geeklog, Anonymous Wednesday, January 15 2025 @ 05:03 pm EST
Geeklog Forums
site slogan in multi-language
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Update:
tgc was right and I was wrong. He just didn't prove it with a link until his next post.
Anyway, being that config.php is an Ascii file while anything non Latin needs non Ascii letters, you also need a way to use non Ascii letters in an Ascii file.
Here's an example (assumes you use Unicode and that your default language is English):
$_CONF['site_slogan'] = iconv('windows-1255', 'utf-8', "something in Hebrew");
elseif (COM_getLanguageId() == "jp")
$_CONF['site_slogan'] = iconv('Ask a Japanese programmer', 'utf-8', "something in Japanese");
else
$_CONF['site_slogan'] = "Finally, direct Ascii in English";
tgc was right and I was wrong. He just didn't prove it with a link until his next post.
Anyway, being that config.php is an Ascii file while anything non Latin needs non Ascii letters, you also need a way to use non Ascii letters in an Ascii file.
Here's an example (assumes you use Unicode and that your default language is English):
Text Formatted Code
if (COM_getLanguageId() == "he")$_CONF['site_slogan'] = iconv('windows-1255', 'utf-8', "something in Hebrew");
elseif (COM_getLanguageId() == "jp")
$_CONF['site_slogan'] = iconv('Ask a Japanese programmer', 'utf-8', "something in Japanese");
else
$_CONF['site_slogan'] = "Finally, direct Ascii in English";
7
5
Quote
Status: offline
tgc
Forum User
Regular Poster
Registered: 03/15/06
Posts: 82
Thank you for your reply, LWC.
I am referring to this here:
http://wiki.geeklog.net/wiki/index.php/Multi-Language_Support
at the bottom there are differerent locale settings which can be changed. It works for me with the date...
I am referring to this here:
http://wiki.geeklog.net/wiki/index.php/Multi-Language_Support
at the bottom there are differerent locale settings which can be changed. It works for me with the date...
9
7
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Let me be the first to say: wow, I was wrong.
I had no idea they did this - I've looked up the history file and turns out it was silently added in v1.4.1rc1. Who knew? Well, you did.
But be it as it may, those locale things still use Ascii letters, while the site's slogan would need iconv for non Latin languages.
Thus I present you my hack for what you wanted. I've tried it myself and it works:
config.php:
$_CONF['site_slogan_he'] = array('×–×ת בדיקה', 'windows-1255');
$_CONF['site_slogan_en'] = 'Plain ascii characters here';
lib-common.php:
function COM_switchLocaleSettings()
{
global $_CONF;
if( isset( $_CONF['languages'] ) && isset( $_CONF['language_files'] ))
{
$overridables = array
(
'locale',
'date', 'daytime', 'shortdate', 'dateonly', 'timeonly',
'week_start', 'hour_mode',
'thousand_separator', 'decimal_separator'
// custom code - start
, 'site_name', 'site_slogan'
// custom code - end
);
$langId = COM_getLanguageId();
foreach( $overridables as $option )
{
if( isset( $_CONF[$option . '_' . $langId] ))
{
// custom code - start
if (substr($option, 0, 5) == 'site_' && is_array($_CONF[$option . '_' . $langId]) && $_CONF['default_charset'] == 'utf-8')
$_CONF[$option] = iconv($_CONF[$option . '_' . $langId][1], 'utf-8', $_CONF[$option . '_' . $langId][0]);
else
// custom code - end
$_CONF[$option] = $_CONF[$option . '_' . $langId];
}
}
}
}
I had no idea they did this - I've looked up the history file and turns out it was silently added in v1.4.1rc1. Who knew? Well, you did.
But be it as it may, those locale things still use Ascii letters, while the site's slogan would need iconv for non Latin languages.
Thus I present you my hack for what you wanted. I've tried it myself and it works:
config.php:
Text Formatted Code
$_CONF['site_slogan_he'] = array('×–×ת בדיקה', 'windows-1255');
$_CONF['site_slogan_en'] = 'Plain ascii characters here';
lib-common.php:
Text Formatted Code
function COM_switchLocaleSettings()
{
global $_CONF;
if( isset( $_CONF['languages'] ) && isset( $_CONF['language_files'] ))
{
$overridables = array
(
'locale',
'date', 'daytime', 'shortdate', 'dateonly', 'timeonly',
'week_start', 'hour_mode',
'thousand_separator', 'decimal_separator'
// custom code - start
, 'site_name', 'site_slogan'
// custom code - end
);
$langId = COM_getLanguageId();
foreach( $overridables as $option )
{
if( isset( $_CONF[$option . '_' . $langId] ))
{
// custom code - start
if (substr($option, 0, 5) == 'site_' && is_array($_CONF[$option . '_' . $langId]) && $_CONF['default_charset'] == 'utf-8')
$_CONF[$option] = iconv($_CONF[$option . '_' . $langId][1], 'utf-8', $_CONF[$option . '_' . $langId][0]);
else
// custom code - end
$_CONF[$option] = $_CONF[$option . '_' . $langId];
}
}
}
}
16
6
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
I hope you've noticed I've also allowed you to use multilingual site names!
Anyway, the above code does what you want, but it assumes 2 things:
1) You default site_name/slogan is in English (unless, of course, you plan to use the iconv function directly). I couldn't think of a way to make the default site_name/slogan participate in the code, as I don't think I should use arrays there because probably too many files rely on that it's not an array...).
2) Your site uses Unicode (I just checked the default).
3) You're smart enough to use arrays for non latin Languages. The arrays look like:
$_CONF['site_name_LANGID'] = array('text in language LANGID', 'charset for language LANGID');
and/or
$_CONF['site_slogan_LANGID'] = array('text in language LANGID', 'charset for language LANGID');
For latin languages, there's no such problem:
$_CONF['site_name_LANGID'] = 'Ascii letters';
and/or
$_CONF['site_slogan_LANGID'] = 'Ascii letters';
Now obviously the last assumption isn't user friendly enough. If someone thinks it's too much, then they can feel free to make two separated settings like those of the languages IDs and languages' names for multilingual sites.
But the bigger trouble is it's not fair to expect the users to mess with charsets' codes. At first I thought about using Geeklog's own language files because each of them declares a charset code, but that's only true for non Unicode files and not all languages there have a non Unicode file.
So what I suggest is for someone to build a big list of charset codes and that way you could do something like:
and, thanks to the person who built the list, Geeklog - instead of the user - would know "_he" (Hebrew)'s charset is windows-1255.
This way we kill two birds with one stone, as there's no longer a need for either arrays or 2 separated settings!
Anyway, the above code does what you want, but it assumes 2 things:
1) You default site_name/slogan is in English (unless, of course, you plan to use the iconv function directly). I couldn't think of a way to make the default site_name/slogan participate in the code, as I don't think I should use arrays there because probably too many files rely on that it's not an array...).
2) Your site uses Unicode (I just checked the default).
3) You're smart enough to use arrays for non latin Languages. The arrays look like:
Text Formatted Code
$_CONF['site_name_LANGID'] = array('text in language LANGID', 'charset for language LANGID');
and/or
$_CONF['site_slogan_LANGID'] = array('text in language LANGID', 'charset for language LANGID');
For latin languages, there's no such problem:
Text Formatted Code
$_CONF['site_name_LANGID'] = 'Ascii letters';
and/or
$_CONF['site_slogan_LANGID'] = 'Ascii letters';
Now obviously the last assumption isn't user friendly enough. If someone thinks it's too much, then they can feel free to make two separated settings like those of the languages IDs and languages' names for multilingual sites.
But the bigger trouble is it's not fair to expect the users to mess with charsets' codes. At first I thought about using Geeklog's own language files because each of them declares a charset code, but that's only true for non Unicode files and not all languages there have a non Unicode file.
So what I suggest is for someone to build a big list of charset codes and that way you could do something like:
Text Formatted Code
$_CONF['site_slogan_he'] = '×–×ת בדיקה';and, thanks to the person who built the list, Geeklog - instead of the user - would know "_he" (Hebrew)'s charset is windows-1255.
This way we kill two birds with one stone, as there's no longer a need for either arrays or 2 separated settings!
6
6
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
You're welcome.
So the question is what will happen if you use a word like Hundehütte or beißt.
Quote by: Wikipedia
German is written using the Latin alphabet. In addition to the 26 standard letters, German has three vowels with Umlaut, namely ä, ö and ü, as well as the Eszett or scharfes S (sharp s) ß.
So the question is what will happen if you use a word like Hundehütte or beißt.
8
7
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
I forgot something. Notepad refuses to save letters in ANSI for languages which charsets you didn't install in your XP. So for those languages, you can't use iconv simply because you can't write the actual letters!
Anyway, here's what I'd do to save letters in French in Notepad in ANSI even though I don't have any French charsets installed:
$_CONF['site_name_fr'] = 'Service client[]le';
$_CONF['site_slogan_fr'] = 'Simulateur de pr{}ts';
$search = array('[]', '{}', '’');
$replace = array(utf8_encode(urldecode('%E8')), utf8_encode(urldecode('%EA')), urlencode('’'));
$_CONF['site_name_fr'] = str_replace($search, $replace, $_CONF['site_name_fr']);
$_CONF['site_slogan_fr'] = str_replace($search, $replace, $_CONF['site_slogan_fr']);
Anyway, here's what I'd do to save letters in French in Notepad in ANSI even though I don't have any French charsets installed:
Text Formatted Code
$_CONF['site_name_fr'] = 'Service client[]le';
$_CONF['site_slogan_fr'] = 'Simulateur de pr{}ts';
$search = array('[]', '{}', '’');
$replace = array(utf8_encode(urldecode('%E8')), utf8_encode(urldecode('%EA')), urlencode('’'));
$_CONF['site_name_fr'] = str_replace($search, $replace, $_CONF['site_name_fr']);
$_CONF['site_slogan_fr'] = str_replace($search, $replace, $_CONF['site_slogan_fr']);
6
8
Quote
Status: offline
tgc
Forum User
Regular Poster
Registered: 03/15/06
Posts: 82
So the question is what will happen if you use a word like Hundehütte or beißt.
If I put it in like this: Hundehütte or beißt, it works for me, although my charset is utf-8. Or would there be szenarios where it won't work?
7
7
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
I see no reason why it should fail, but you better test it to know for sure.
You're just using HTML encoding while I used URL decoding (+UTF-8 encoding when needed). The only reason I chose the latter was because there's no HTML encoding functions in PHP and it has to be done manually like you did.
Then again, as I have to declare the URL encoding's "dictionary" manualy, I guess it doesn't matter that much.
Maybe someone who knows these things would tell us what is the better approach.
I thought of creating a dictionary (in either way), but how many variations like {} can I come up with? And how can this ever be user friendly - how would the average user know they can even use those things - be them direct HTML encoding or variations like {}?
You're just using HTML encoding while I used URL decoding (+UTF-8 encoding when needed). The only reason I chose the latter was because there's no HTML encoding functions in PHP and it has to be done manually like you did.
Then again, as I have to declare the URL encoding's "dictionary" manualy, I guess it doesn't matter that much.
Maybe someone who knows these things would tell us what is the better approach.
I thought of creating a dictionary (in either way), but how many variations like {} can I come up with? And how can this ever be user friendly - how would the average user know they can even use those things - be them direct HTML encoding or variations like {}?
6
6
Quote
Status: offline
tgc
Forum User
Regular Poster
Registered: 03/15/06
Posts: 82
this html thing is good enough for me because I am not changing the site slogan often and I know my code for my umlauts.
But do you happen to know how I can add a small flag indicating the language and also changing with it?
Thank you
updated
I found it: just put the link to the respective flag images in config.php (before I had the wrong path and it didn't work).
But do you happen to know how I can add a small flag indicating the language and also changing with it?
Thank you
updated
I found it: just put the link to the respective flag images in config.php (before I had the wrong path and it didn't work).
6
8
Quote
All times are EST. The time is now 05:03 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content