语言翻译语法 [英] Language translate grammar

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

问题描述

我正在尝试为我的项目添加另一种语言.

我们知道语言可以显示主语和谓语的差异.例如:

英语:Mustafa今天和他的朋友ahmet去看电影了.

土耳其语:Mustafa bugün arkadaşı ahmet ile birlikte sinemaya gitti.

英语 - 土耳其语

今天 => 错误

sinema => 电影院

birlikte => 与

gitti => 去了

Mustafa 和 ahmet 是用户表中的用户名.我的问题是如何显示具有良好语法的单词?

如果我想在我的语言表中添加我的示例词,我该怎么做?我问这个是因为这个例子:

$username =>穆斯塔法,$朋友名=>艾哈迈德

英文:<?php echo $username;?> 今天和他的朋友 去看电影了.

土耳其语:<?php echo $username;?> bugün arkadaşı <?php echo $friendname;?> ile birlikte sinemaya gitti.>

如您所见,特殊名称位于不同的位置.如何在不回显的情况下显示表中的用户名?

解决方案

为什么不在定义的句子上使用占位符.

$sentences = array();$sentences[ "en" ] = "{{USERNAME}} 今天和他的朋友 {{FRIENDNAME}} 去看电影了.";$sentences[ "tu" ] = "{{USERNAME}} bugün arkadaşı {{FRIENDNAME}} ile birlikte sinemaya gitti.";

将名称和占位符放在数组上

$placeHolder = [ "{{USERNAME}}", "{{FRIENDNAME}}" ];$name = [ "Mustafa", "ahmet" ];

如果您选择打印EN

echo str_replace($placeHolder, $name, $sentences[ "en" ]);

将导致:Mustafa 今天和他的朋友 ahmet 去看电影了.

如果您选择打印TU

echo str_replace($placeHolder, $name, $sentences[ "tu" ]);

将导致:Mustafa bugün arkadaşı ahmet ile birlikte sinemaya gitti.

I am trying to add another language for my project.

We know that languages can show differences in subject and predicate. For example:

English: Mustafa went to the cinema with his friend ahmet today.

Turkish: Mustafa bugün arkadaşı ahmet ile birlikte sinemaya gitti.

English - Turkish

today => bugün

sinema => cinema

birlikte => with

gitti => went

Mustafa and ahmet is username from users table. My question is how can I show the words with good grammars?

If I want to add my example word in my language table what should I do? I am asking this because of this example:

$username => Mustafa,

$friendname => ahmet

English: <?php echo $username;?> went to the cinema with his friend <?php echo $friendname;?> today.

Turkish: <?php echo $username;?> bugün arkadaşı <?php echo $friendname;?> ile birlikte sinemaya gitti.

As you can see, the special names are in different places. How can I show the usernames from the table without echoing it?

解决方案

Why dont use placeholder on defined sentences.

$sentences = array();
$sentences[ "en" ] = "{{USERNAME}} went to the cinema with his friend {{FRIENDNAME}} today.";
$sentences[ "tu" ] = "{{USERNAME}} bugün arkadaşı {{FRIENDNAME}} ile birlikte sinemaya gitti.";

Put the name and placeholders on array

$placeHolder    = [ "{{USERNAME}}", "{{FRIENDNAME}}" ];
$name           = [ "Mustafa", "ahmet" ];

If you choose to print EN

echo str_replace($placeHolder, $name, $sentences[ "en" ]);

Will result to: Mustafa went to the cinema with his friend ahmet today.

If you choose to print TU

echo str_replace($placeHolder, $name, $sentences[ "tu" ]);

Will result to: Mustafa bugün arkadaşı ahmet ile birlikte sinemaya gitti.

这篇关于语言翻译语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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