翻译月份名称的最佳方式 [英] Best way to translate month names
问题描述
我使用Codeigniter!什么是翻译月份名称的最佳方式。我有一个日期在mysql时间戳像这样:
2012-09-22 11:21:53
我可以将其转换为'2012年9月22日'
使用php date()
函数。我想将'September'
重命名为'Sentýabr'
。可以set_locale()函数可以做到这一点。顺便说一句,土库曼语言
。
谢谢。
好吧,我创建了一个php文件来检查它像这样:
cool.php
<?php setlocale(LC_ALL,'ru_RU' );
echo strftime('%B',time());
?>
返回9月。可能有问题。
<$>
我有
/ *将区域设置为Turkmen * /
setlocale(LC_ALL,'tk');
和
echo strftime('%B',time());
结果:返回September
它会以我的语言返回9月
您可以使用 str_ireplace()
这样的东西:
pre> $ nmeng = array('january','february',..);
$ nmtur = array('ocak','subat',...);
$ dt ='2012年9月22日';
$ dt = str_ireplace($ nmeng,$ nmtur,$ dt);
I am using Codeigniter! What will be the best way to translate month names. I have a date in mysql timestamp like this:
2012-09-22 11:21:53
I can convert it to 'September 22, 2012'
with php date()
function. I want to rename 'September'
to 'Sentýabr'
. Can set_locale() function can do this. By the way it is Turkmen Language
.
thank you.
OK , i created some php file to check it indivudally like this:
cool.php
<?php setlocale(LC_ALL,'ru_RU');
echo strftime('%B',time());
?>
Returns September. What might be the problem.
I have
/* Set locale to Turkmen */
setlocale(LC_ALL, 'tk');
And
echo strftime( '%B',time());
Result: returns September
I need it return September in my language
You can use str_ireplace()
with arrays for names in english, and equivalent for names in turkmen, in same order.
Something like this:
$nmeng = array('january', 'february', ..);
$nmtur = array('ocak', 'subat', ...);
$dt = 'September 22, 2012';
$dt = str_ireplace($nmeng, $nmtur, $dt);
这篇关于翻译月份名称的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!