路依聖諾文翻譯語言翻譯公司


plural:

天成翻譯社是用react-18next來實作多說話功能 別的搭配免費的oneSky來做雲端翻譯管理

在翻譯中帶入已有的翻譯

共勉之~

 

jsx:
import { translate, Interpolate } from 'react-i18next'
<span>
<Interpolate i18nKey="common:sleep early"
                    br={<br/>} />
</span>

<p>
<Interpolate i18nKey="common:weather today"
                    adj={<strong>{t('common:very')}</strong>} />
</p>

<p>
The weather is very good
</p>

就會顯示


Nested 巢狀:

目的就是要讓網頁用翻譯的值代替翻譯的key

const daysVariable = 3

 

<div>
我是jojo
</div>

翻譯社

翻譯社 { name: UserName })}
</div>

在此分享下使用的筆記

3. 單複數 

<span>
Route A would take 3 days, Route B would take 1 day.
</span>
----------

jsx:

-------

{
"weather today":"今天天氣{{adj}}好"翻譯社
"very":"特別很是"
}

例如 斷行符號<br/>

Interpolate:

6.在interpolate 中帶入其他翻譯值

<div>
3 days
</div>
不需要由前端來判定是單數還是複數 很輕易
不外有時候接到的數字多是字串情勢 ("3")
jsx就要改寫為
{t('common:dayCount'翻譯社 { count: Number(daysVariable) } }

-------

jsx:

import React翻譯社 { Component } from 'react'
import { translate } from 'react-i18next'

就會顯示

export default MyItem

4.插入html tag

<p>
The weather is <strong>very</strong> good
</p>

2.帶入參數 像是顯示人名

json:

雷同variable翻譯社 用於帶入htmltag到翻譯中的時候

{
    "key1":"翻譯的文字"
}

例如
<p>
今每天氣<strong>非常</strong>好
</p>

@translate(['user', 'common'])
class MyItem extends Component {
    const { t } = this.props
    return 
    <div>
    {t('common:key1'}
    </div>
}

<span>
{t('common:Route take', { Adays: daysA_variable翻譯社 Bdays: daysB_variable })}
</span>

translate json:
{
 "dayCount":"{{count}} day",
 "dayCount_plural":"{{count}} days"翻譯社
}

json:
{
"Route take":"Route A would take $t(common:dayCount, {\"count\": {{Adays}} }), Route B would take $t(common:dayCount, {\"count\": {{Bdays}} })."翻譯社
"dayCount":"{{count}} day",
"dayCount_plural":"{{count}} days"
}

1.入門 顯示翻譯值

<div>
    {t('common:dayCount', { count: daysVariable } }
</div>

就會呈現

 

例如
<span>
早睡夙興<br/>
身體好
</span>

jsx:
import { translate, Interpolate } from 'react-i18next'


translate json:

class jsx:

例如:
A線路需時3天,B線路需時1天
Route A would take 3 days, Route B would take 1 day.

比來用react做了多說話功能

---------

另外還有oneSky的利用心得 還有i18next的 preload再找時候寫好了

 

variable:

翻譯的文字有時候會帶入參數, 像是人名 所在...

就會泛起

以上, 做個記載分享

<div>
翻譯的文字
</div>

5.巢狀的翻譯

const UserName = 'jojo'

json:

jsx:

來轉型,
別的!!
count 是套件的內定字元 若是variable改成其他字就不會主動判斷了
我之前就用amount來傳數目參數 都沒有反映(固然...) 然後弄了半小時才搞懂這個規則
---------

<span>
早睡早起
身體好
</span>

 



本文來自: http://jojomango.pixnet.net/blog/post/235255036-react-%E7%BF%BB%E8%AD%AF-i18next--snippets有關翻譯的問題歡迎諮詢天成翻譯社

arrow
arrow
    創作者介紹
    創作者 nelliea13i7 的頭像
    nelliea13i7

    sheilape58308

    nelliea13i7 發表在 痞客邦 留言(0) 人氣()