在刀片文件上使用Poedit

时间:2018-07-09 15:12:53

标签: php translation laravel-blade poedit

我正在使用Poedit创建我的翻译文件。但是在我们的项目中,Poedit无法识别任何此类翻译。

<span>{{translate('Services')}}</span>

我正在使用笔译作为关键字。

它可以在php标记内运行,就像这样,但我不希望这样做。

<span><?php echo translate('Services'); ?></span>

根据我的搜索结果,正在使用的Poedit 2.0应该能够理解刀片文件中的此类标签,但显然无法正常工作。

我可以做一些配置更改吗?

谢谢

1 个答案:

答案 0 :(得分:0)

我不知道Laravel内置的任何可以处理.po文件的东西,但那里可能有可用的软件包。

传统上,在Laravel中,翻译的文本是通过在<table class="table table-bordered table-hover"> <tr> <!-- start initial row --> <? $counter = 1; foreach ($pin_data as $pin):?> <td> <?= $pin->location;?> <?= $pin->pincode;?> </td> <?if($counter % 5 == 0):?> //if $counter is a multiple of 5, close the current row and start an new one </tr> <tr> <?endif;?> <? $counter++;?> <?endforeach;?> </table> (或resources/lang/en下的另一个语言目录)中定义语言文件来处理的。

要从语言文件中获取文本,可以在刀片中使用resources/lang帮助程序功能。

有关本地化和语言文件的更多信息: https://laravel.com/docs/5.6/localization#introduction

一个基本示例:

resources / lang / zh-cn / tests.php

trans()

resources / views / tests.blade.php

return [
'one' => 'This is test one!',
'two' => 'This is test two!'
];

产生:

<p>Hello world! {{trans('tests.one')}}</p>