| Project: | ProjectPier |
| Version: | 0.8.5.0-Beta1 |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed - fixed |
There are some places in templates where strtolower used with translated strings
For example application\views\files\del_file.php
<?php
<div><?php echo lang('about to delete')
?><?php
echo strtolower(lang('folder'))
?>
<?php
echo clean($folder->getName())
?>
?>
lang('folder') returns utf-8 string but strtolower() works only with ascii letters
It breaks russian letters so users see ����
http://php.net/manual/en/function.strtolower.php
Note that 'alphabetic' is determined by the current locale. This means that in i.e. the default "C" locale, characters such as umlaut-A (Ä) will not be converted.
setlocale() is not helpful in most cases so better replace all occurrences of strtlower to mb_strtolower('...', 'UTF-8')
It's not hard to make a patch - there's a few occurrences but PP starts depends on MB_STRING extension...
Any other ideas?
This bug only on delete pages and 2 occurrences on dashboard with lang('in')
patch against (revision 161)
Hi andypost,
I looked at the patch and I have a few comments:
- I couldn't reproduce what you're describing about the Russian characters appearing as ����. I tried on Safari 3 and Firefox 3 on Mac.
- I have seen that cakePHP has a file multibyte.php which redefines all the mb_strfoobar functions if they are not defined already. See http://api.cakephp.org/multibyte_8php-source.html
Should we add something like that too? You said on IRC that mb_strtolower is now standard in PHP, so if it is, we don't have to worry about that. Do you know if there are any reason why it wouldn't be defined?
- overall, I don't have anything bad to say about this patch as long as the function is defined and that it doesn't need to be called at other places (which wouldn't be a problem in itself, but if we can fix the problem once and for all that's better)
So, as far as I'm concerned, if you can answer to my comments above, this would be ready for commit.
Tim, you right about cake - if there's no mb_string php-extention they use internal functions same as drupal (drupal_strlen for ex)
So there'a only one question - should we use direct functions or function-wrappers as you show above?
My opinion is to make wrappers! Because PP multilang we need correct str_len and other functions works fine with multibyte chars.
Accepted in 0.8.6. Wrapper function created:
function lc($string) {
return utf8_encode(strtolower(utf8_decode($string)));
}
Tested with Milestone changed to Milestonä and then delete.
Milestonä was displayed as milestonä :-)