用poedit和zend翻译数据库的翻译 [英] Translation of database with poedit and zend translate

查看:126
本文介绍了用poedit和zend翻译数据库的翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Poedit不会自动识别数据库中表的内容。
什么是获取由poedit识别的表的内容在zend中的翻译的最佳方式。我想要自动完成....我必须从数据库创建一个xml文件?

解决方案

你不应该用poedit翻译数据库内容。你会在数据库中做到这一点。简单的答案:你想要的是不可能实现的,不幸的是,您可以翻译固定字符串,如果要获取变量,常量或数据库值翻译,您可以必须通过文字字符串翻译来做,在这种情况下,poedit必须扫描它们:

 <?php 
if($ var ==='foo'){
echo $ this-> translate('foo');
} else {
echo $ this-> translate('bar');
}

如果与$ $ c $ 1:n关系更容易c>翻译对象。该视图将从用户生成的内容中提取翻译:

 <?php 
echo $ foo->翻译[ 'EN-US'] - >酒吧;

Gedmo教义扩展中提供了最后一种可能性的示例: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md


Poedit does not automatically recognise the content of a table in a database. What is the best way to get the content of a table recognized by poedit for its translation in zend. I would like it to be done automatically....do I have to create an xml file from the database ?

解决方案

You should not translate database contents with poedit. You would do that inside the database. The short answer: what you want cannot be achieved, unfortunately.

You can translate "fixed" strings and if you want to get variables, constant or database values translated, you have to do that via literal string translations, in the case poedit has to scan them:

<?php
if($var === 'foo') {
    echo $this->translate('foo');
} else {
    echo $this->translate('bar');
}

It's easier if you have a 1:n relation with a Translation object. The view would then pull the translation from user generated content:

<?php
echo $foo->Translation['en-us']->bar;

An example of this last possibility is provided in the Gedmo doctrine extension: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md

这篇关于用poedit和zend翻译数据库的翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆