Adding fr_FR support
Posted by: NeoTechni (---.home1.cgocable.net)
Date: April 15, 2015 09:30PM

I'm trying to add multi lingual support in PHP. It loads en_US just fine, which doesn't matter since that's what the site was in to begin with. But once I load fr_FR, gettext() returns the text ID instead of the translation. The directory structure isn't the problem.

Options: ReplyQuote
Re: Adding fr_FR support
Posted by: NeoTechni (---.home1.cgocable.net)
Date: April 15, 2015 09:31PM

1 - Windows version used (Specify version number AND whether 32 or 64 bit)
Windows 7 64 bit

2 - Version WampServer (Specify version number AND whether 32 or 64 bit)
WampServer Version 2.5, don't know how many bits

3 - Apache Version
2.4.9

4 - PHP Version
5.5.12

5 - MySQL Version
5.6.17

6 - What color is the WampServer icon (in the notification area of the taskbar)
green

7 - In the file c:\Windows\System32\drivers\etc\hosts, what are the active lines with the name [localhost] in them?
* Active means no # at the beginning of the line.
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost

If the WampServer icon is green:

8 - Do you have access to localhost (Homepage WampServer)?
yes

9 - Do you have access to phpMyAdmin?
yes

10 - If you refer to an error message, please include the EXACT wording of the error in your post
none given

11 - If you use an Antivirus and / or Firewall, please include the names of these
no

12 - What is the full path to the installation of WampServer (eg D:\wamp\)
C:\wamp



Edited 2 time(s). Last edit at 04/15/2015 09:38PM by NeoTechni.

Options: ReplyQuote
Re: Adding fr_FR support
Posted by: RiggsFolly (---.as43234.net)
Date: April 15, 2015 10:27PM

Hi,

Its not that easy to debug code that you cannot see.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Adding fr_FR support
Posted by: NeoTechni (---.home1.cgocable.net)
Date: April 15, 2015 10:31PM

The code isn't the problem. It's gettext() not loading the locale, and I don't know how to install it. The system works perfectly for en_US, but when I pass it fr_FR it fails.

But if you insist:


function translate($language, $flushcache = false){
//veritas3-0\webroot\Locale\[language]\LC_MESSAGES will need clearing of duplicate mo files
//$language="fr_CA";
putenv("LANG=$language"winking smiley;
putenv("LANGUAGE=$language"winking smiley;
putenv("LC_ALL=$language"winking smiley;
setlocale(LC_ALL, $language);//.UTF-8
$domain = 'default';
$dir= getcwd() . "/Locale";
if($flushcache){//MUST NOT USE ON LIVE!
$path = $dir . "/" . $language . "/LC_MESSAGES/";
$filename = $path . $domain . ".mo" ;
$mtime = filemtime($filename);
$filename_new = $path . $domain . $mtime . ".mo" ;
if (!file_exists($filename_new)){
copy($filename,$filename_new);
}
$domain = $domain . $mtime;
}
bindtextdomain($domain, $dir);//www/veritsa3-0/, Locale
textdomain($domain);
if(gettext("test"winking smiley=="test"winking smiley{
echo $language . " is not installed on this system.";
}
return $language;
}

Options: ReplyQuote


Sorry, only registered users may post in this forum.