I'm trying to solve a Internationalization problem with CakePHP but I cant get cake to start localizing... even though I have everything set up as the documentation requires... my problem is twofold:
first I'd like cake to localize all __(''); strings I defined in the views. The second thing is that I have a datetime input field which I'd like to localize as well...
currently my Locale folder looks as follows:
/Locale
-cake_dev.pot
-cake.pot
-default.pot
-/DE/LC_MESSAGES/
--default.pot
and in my /config/bootstrap.php the last line is:
Configure::write('Config.language', 'DE');
thx so much for your support!
Indeed it should be deu. And you need rename deu/LC_MESSAGES/default.pot to deu/LC_MESSAGES/default.po, open it in poedit, update it (catalog) from default.pot and translate it. On save deu/LC_MESSAGES/default.mo will be compiled, this file is used by cake.
I'm not sure if Cake internally converts DE to DEU, further it should be lower cased. Systems other than windows are case sensitive. So try "deu" instead of "DE".
Related
I installed gettext on a server and want to use for a php script..
I use with 3 languages. The original website is written in english..
Other are french and Italian.
I can without problem change language to French or Italian.. But when I want load the en_EN.mo file to replace the origine text of the php file, the translation are not loaded.
I try many things.. Remove file, replace name.. restart apache..
Nothing.. it work perfectly with all other langage, but impossible to use a english file.
I create new language.. it work too.. but never the en_EN..
All my files langage are in the same tree style
locale
en_EN
LC_MESSAGES
en_EN.mo
fr_FR
LC_MESSAGES
fr_FR.mo
...
if I force to use..
$directory = './locale';
$domain ='en_EN';
$locale ='en_EN';
putenv('LC_ALL='.$locale);
setlocale(LC_ALL, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');
no result..
My problem is that I have no idea how to debug it ? Where can I find a log or something to help ? Where see errors ?
It's strange that it work with all lang, but not english.. I use Poedit to create my file, I have create the file many time.. in the same way that other..
Please share your idea :)
I create new language.. it work too.. but never the en_EN..
You misunderstand what the locale string means. It is not “2 language code letters followed by the same letters in uppercase” (that wouldn’t make any sense, would it), it is “language code followed by country code” per ISO 3166. And “EN” is not only not a valid country code for any country that speaks English, it’s not a valid country at all. You’re asking WordPress to run under the English locale (presumably), but only providing it translation files for “English in a made-up country” locale that WP is never going to look for.
You’re thinking of en_US.
I've been trying to find a way to search a directory with multiple criteria in PHP with little luck.
I have a folder that contains multiple versions of the same file but in different languages and for different devices:
e.g.
1. file_en_v980.jar
2. file_fr_v980.jar
3. file_en_v990.jar
4. file_fr_v990.jar
I want to be able to search the directory for all English (en) .jar files for the v980.
I've tried this:
foreach(glob('./'.$installer_location.'/'.$brand_name.'/*en*.jar') as $filename){
echo $filename."</br>";
}
It works, but returns the french (fr) file too.
I've tried this:
foreach(glob('./'.$installer_location.'/'.$brand_name.'/*en,v980*.jar') as $filename){
echo $filename."</br>";
}
But it returns nothing so I'm assuming I've got the syntax wrong.
Any help would be greatly appreciated.
Addition:
Based on the suggestion from the comment below I tried this:
foreach(glob('./'.$installer_location.'/'.$brand_name.'/*{en,v980}*.jar',GLOB_BRACE) as $filename){
echo $filename."</br>";
}
This returned all the files that had either en, v980 or both. I just need to figure out if there is a way to say must contain both.
PHP's glob() essentially uses the same wildcarding/matching engine as a unix shell. With your version, you're searching for files that contain en,v980, and it's not being treated as "alternation". http://www.tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm
Try
glob('..../*{en,v980}*.jar')
instead (note the {})
I would like my php website to be able to be multilinguistic. I thought of using:
echo $lang[$_SESSION['lang']]['WellcomeMessage'];
but I found that I will be needing to format the text, say for example male/female or putting some values from the DB. So I thought that simple strings might not do the trick for formatting?
I know #define might have worked in C as the string translates to code, but I don't know how php does that. For example:
define ($lang['en']['credit_left'],'you have $credits_left');
define ($lang['sp']['credit_left'],'tienes $credits_left creditos mas');
Any suggestions?
In a Symfony project, I have the following php code inside a YML file. I was hoping this code would read another yml file and modify the content based upon its value. However, sfYaml::load is returning a string instead of an array. Any ideas why this might be?
In the following code, I expected $s to contain an array, but instead it contains a string with the value "../config/server_settings.yml".
From databases.yml:
dsn: mysql:host=myhost;dbname=mydbname<?php $s = sfYaml::load('../config/server_settings.yml');var_dump($s); ?>
It looks like it's treating your input as a string of yml content, possibly because it can't find the file. Try using the full path or some quick debugging with is_file('../config/server_settings.yml')
It looks like you're trying to define custom settings.
Perhaps this page might help you out:
http://trac.symfony-project.org/wiki/HowToCacheCustomConfiguration
In short I am looking for something like google-diff-match-patch in PHP.
I have had a look at some similar questions at SO, and also at the algorithm provided here, but all of them fail:
diff("draßen", "da draußen")
should not give
<del>draßen</del> <ins>da draußen</ins>
(which is kind of stupid for my purpose, because I want to compare file names), but (try here)
<ins>da </ins>dra<ins>u</ins>ßen
Is there a code snippet in PHP that does this? Unfortunately, I cannot use (i.e. install) external packages.
https://github.com/gorhill/PHP-FineDiff supports character-wise diff and can render the differences in HTML
The PEAR Package Text_Diff provides Inline-Diffs.
There is a php version of google-diff-match-patch available here: https://github.com/nuxodin/diff_match_patch-php
There is a port of fresh version google-diff-match-patch library.
It is much faster than previous and have no problems wth utf8.