Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 2 3 [4]

Author Topic: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)  (Read 17379 times)

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 405
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #45 on: January 25, 2008, 03:31:44 AM »

Hungarian:

Code: [Select]
function deLocalize( inStr ) {
var outStr = inStr;
outStr = outStr.replace(/[áÁ]/g, 'a');
outStr = outStr.replace(/[éÉ]/g, 'e');
outStr = outStr.replace(/[íI]/g, 'i');
outStr = outStr.replace(/[óÓ]/g, 'o');
outStr = outStr.replace(/[öÖ]/g, 'o');
outStr = outStr.replace(/[üÜ]/g, 'u');
outStr = outStr.replace(/[úÚ]/g, 'u');
return outStr;
}
« Last Edit: February 02, 2008, 01:17:54 PM by henrich »
Logged
By(e) Henrich :)
------------------------------
IT related blog

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 405
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #46 on: January 31, 2008, 07:22:10 AM »

So there is any chance to have different charset under different languages?

Let's say under english to have UTF-8 and under hungarian ISO-8859-1 charset.
Logged
By(e) Henrich :)
------------------------------
IT related blog

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 450
  • Posts: 6162
  • Semantically Challenged
    • snews.ca
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #47 on: January 31, 2008, 05:58:10 PM »

So there is any chance to have different charset under different languages?
Let's say under english to have UTF-8 and under hungarian ISO-8859-1 charset.
Heinrich... when you create your site's database, phpMyAdmin (MySQL) lets you choose which charset it will use. When you create your tables, you can also choose which charset they will use. Whichever charset you choose during these steps is what you want to enter in as the "default" charset field in the SETTINGS >> TIME & LANGUAGE Settings panel in the sNews Admin. Once these are set, that is the way they will be... because there is no way to make MySQL switch the charset as it is applied to the database and its tables & content.

If you wanted to have content published in different languages that require different charsets... and you wanted to use sNews... I think your best approach would be to create separate installations in the same domain for each language. Each would use its own database and tables with the appropriate charset chosen and used for that language. The index.php file in each installation can use the same template and css styles so that they would all look like they were on the "same website".
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 405
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #48 on: January 31, 2008, 06:32:21 PM »

Bad to read this, i am using ML from Rui, i was thinking to add some statements in the title() function, like if language equal hungarian then charset to be iso...., else to be the default inserted from the admin panel. Regarding the database charset ... i just know one good thing, i played with the charset in the admin, when it was utf-8 it was good for english, when it was iso.... the hungarian characters was shown perfect with diacritics, now what do you say about this Keyrocks? Maybe there is still a chance to accomplish my wish?!  ;D
Logged
By(e) Henrich :)
------------------------------
IT related blog

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 450
  • Posts: 6162
  • Semantically Challenged
    • snews.ca
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #49 on: January 31, 2008, 08:55:05 PM »

I played with the charset in the admin, when it was utf-8 it was good for english, when it was iso.... the hungarian characters was shown perfect with diacritics, now what do you say about this Keyrocks? Maybe there is still a chance to accomplish my wish?!  ;D

Can't say much (if anything) about that at all. I am no expert on the use of different languages with sNews. Perhaps there is something about the charset switch in Admin that solves the whole thing... I don't know... never really looked at it in-depth before. So... best advice... do like the rest of us... keep on experimenting until Luka (or someone else) comes up with a clear explanation on this matter. ;D
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 405
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #50 on: January 31, 2008, 09:14:24 PM »

 ;D sure, i will post here if any positive result i will have.
Logged
By(e) Henrich :)
------------------------------
IT related blog

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 405
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #51 on: February 01, 2008, 04:02:17 AM »

What is the simplest way to get the current "lang" value to write an if statement? Let's say:

Quote
if ($lang == 'EN') { ......
Logged
By(e) Henrich :)
------------------------------
IT related blog

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 450
  • Posts: 6162
  • Semantically Challenged
    • snews.ca
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #52 on: February 01, 2008, 02:43:54 PM »

Just have a look at the opening strings within the existing snews.php language array:

Code: [Select]
<?php

if (s('language') != 'EN' && file_exists('snews_'.s('language').'.php')) {
     include(
'snews_'.s('language').'.php');
     } else {
     
$l = array();
          
// followed by all of the language variables within the array
     
} return $l[$variable];

?>


In this case, there's an ! just before the first equal sign so this bit of script is saying...
     "If the current language IS NOT English - and - a file for the current language exists,
      include the the file named for the current language,
      else
      continue parsing the rest of this array."


The current value "lang" value is stored in the settings dbase table and... like all values in the settings table... it is expressed in snews.php functions as and "s" variable with the variable name in the brackets -  s('language'). To use $lang as the variable in your script, you would first define its value using the expression s('language').  For example...

Code: [Select]
<?php

$lang 
s('language');
if (
$lang == 'EN') {
     
# do something here
     
} else {
     
# do something else
     
}

?>


... would be interpreted as:
      "$lang is the current language value in the settings table.
     If the current language value is EQUAL TO English,
     do something here.
    Else...
    do something else."

« Last Edit: February 01, 2008, 02:47:03 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

henrich

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 405
  • Passion for quality and excellence!
    • My personal blog and portofolio
Re: [MOD] Generate readable non-english SEF titles (sNews 1.6, 1.5)
« Reply #53 on: February 01, 2008, 08:43:19 PM »

YESSSS :P Keyrocks, i think this will be good, i will test it later and adapt it to my "vision"  ;D

Later add-on:

Quote
//$lang = s('language');
$lang = ''.$_SESSION[db('website').'lang'].'';
if ($lang == 'HU') {
echo '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />';
} else {
echo '<meta http-equiv="Content-Type" content="text/html; charset='.s('charset').'" />';
}

I commented out the $lang = s('language'); as have not returned any lang value so i took from session the language.


P.S.: What do you say, it would be an intelligent thing to create another main section on this forum, as the MU has one, to have also ML, i have 8 MODs written so far, some of them are based on ML (1 or 2, old or current MOD adapted to ML), maybe those should be moved to a "ML" section. Just an idea, i don't regret current situation but maybe there peoples who are not using ML and are not interested on ML topics like current topic or other ML based topics. Under ML i understand first the MOD created by Rui Mendes.
« Last Edit: February 01, 2008, 10:34:52 PM by henrich »
Logged
By(e) Henrich :)
------------------------------
IT related blog
Pages: 1 2 3 [4]