- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用非常标准的 facebooks create-react-app 构建一个 React 应用
我正在使用 i18next 来支持本地化,我也需要多元化,我正在使用 ICU 来支持多元化,这里是支持多元化的 ICU 格式示例。
"VALID_FOR_DAYS": "{count, plural, one{Valid for {count} more day} other{Valid for {count} more days}}",
这是我在我的 React 项目中的 i18 配置
import i18n from 'i18next';
import I18nextIcu from 'i18next-icu';
const icu = new I18nextIcu();
export const initilizeLocaleSettings = async (defaultLocale: string): Promise<void> => {
await i18n
.use(icu)
.use(initReactI18next)
.init({
resources: {
en: {
translation: {
WELCOME: 'Welcome {{name}}',
VALID_FOR_DAYS": "{count, plural, one{Valid for {count} more day} other{Valid for {count} more days}}",
}
}
},
lng: defaultLocale,
fallbackLng: defaultLocale,
interpolation: {
escapeValue: false
}
});
};
import { useTranslation } from 'react-i18next';
function App() {
const { t } = useTranslation();
return (
<h1>
{t('VALID_FOR_DAYS', { count: 10 })}
{t('WELCOME', { name: 'JOHN DOE' })}
</h1>
);
}
复数化效果很好 VALID_DAYS 得到完美翻译但是 WELCOME 它不会给我以下错误
语法错误:应为“0”、[1-9] 或 [^\t\n\r,.+={}#] 但找到了“{”。
最佳答案
欣赏这是前一段时间,但你不需要双花括号:
这个:
translation: {
WELCOME: 'Welcome {{name}}',
VALID_FOR_DAYS": "{count, plural, one{Valid for {count} more day} other{Valid for {count} more days}}",
}
应该是:
translation: {
WELCOME: 'Welcome {name}',
VALID_FOR_DAYS": "{count, plural, one{Valid for {count} more day} other{Valid for {count} more days}}",
}
关于reactjs - i18next-icu 在 react 中翻译时不支持 {{(双括号),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59901057/
我正在尝试学习 ICU 语法并希望能够表达在 ICU message format 中列出. 例如,给定数据: items: - cool - handy - neat 我希望能够生成如下
是否可以获得适当的大写,例如使用 ICU4C 的英文文本但没有构建任何自定义的非大写单词集?比如说,鉴于对峡湾的渴望,我希望获得对峡湾的渴望。 使用 ucasemap_utf8ToTitle() 和
我想编译 icu sqlite extension静态链接到 icu . 这是我试过的,也许错误对你来说是显而易见的。 > cd icu/source> ./runConfigureIcu Linux
我试图将我们 CI 环境中的 Node 版本从 Node 6 升级到 Node 8。我也更新了完整的 icu 版本。 $NODE_ICU_DATA 设置为 /usr/lib/node_modules/
我今天开始使用最新的 Android Build Tools (ABT) v19.0.3 收到消息。乍一看,我认为这可能是 ABT 的问题。然而,更仔细的调查显示这条消息: android.suppo
unicode 排序背后的理论是什么?我明白它是如何工作的,但我不明白为什么 they决定采用此标准进行归类排序。 似乎当您有两个字符串要比较时,例如使用 ucol_strcolliter(): uc
我的应用程序可能在一个列表中包含由不同字母/语言组成的字符串。我似乎无法找到有关对这些进行排序的正确方法应该是什么的任何信息,或者任何表明 ICU 支持此功能的迹象。 示例列表: 苹果 яблоко
如何在iPhone应用程序的工作区中使用ICU(Unicode国际组件)将sqlite编译为项目? 我之前已经编译了sqlite合并,但是我不确定应该下载哪些文件以及需要将哪些脚本添加到xcode中-
我正在尝试使用 ICU 音译器对某些文本进行非常具体的转换,如 here 所述. 我的文本包含半角片假名字符和常规拉丁字符。我想将半角片假名转换为全角片假名,同时保持非片假名字符不变。 我想简单地应用
有没有办法探测ICU library对于所有 UChar's表示库支持的货币符号? 我当前的解决方案是遍历所有语言环境并针对每个语言环境,执行如下操作: const DecimalFormatSymb
谁能解释为什么下面的比较不相等? void CompareTest() { UErrorCode status = U_ZERO_ERROR; UChar ruleset[500]; *rul
有没有办法探测 ICU最小面额的货币区域设置?例如,美国为 0.01 美元,韩国 (ko_KR) 为 ₩1。我想在 DecimalFormat object 上调用 getRoundingIncrem
我正在创建 SQLite3 的自定义构建,我想实现不区分大小写的文本列。 是否可以创建不区分大小写的排序规则? 最佳答案 你可能想调用 ucol_setStrength具有 UCOL_PRIMARY
我们有使用 ICU 库处理 Unicode 字符串的代码。当我们尝试构建它时,没有出现编译错误,但链接失败了。我用以下代码创建了一个小测试程序: #define U_STATIC_IMPLEMENTA
有人知道 ICU 字符集检测器的数据是如何构建的吗?添加其他语言是否困难? 例如,我在错误跟踪器中看到,自 2007 年以来就打开了检测泰语的票证,但直到今天都没有新内容。 谢谢 最佳答案 我会在 I
您好,我将我的sql语句修改为 CREATE VIRTUAL TABLE [v_fts] USING fts4 ( [title], tokenize=icu )" 但是当我尝试插入数据时出现错误
我的目标是逐个字符地迭代 Unicode 文本字符串,但下面的代码迭代的是代码单元而不是代码点,即使我使用的是 next32PostInc () 应该迭代代码点: void iterate_codep
是否可以在不退回到正则表达式的情况下使用 ICU 完成? 目前我规范化文件名是这样的: protected function normalizeFilename($filename) { $t
我了解 ICU 的本地化部分 - 日期、时间和货币格式、整理等。在消息翻译方面,我看到有人说 ICU 不提供消息翻译功能 - 例如查看 this SOF question . 但是,在查看 ICU 文
我想知道是否有一种方法可以在 ICU (c++) 库中引用字符串。存在 "\Q"+ string + "\E"但我生成的输入作为提供的字符串输入。似乎没有任何 ICU 引用正则表达式方法。只需将字符串
我是一名优秀的程序员,十分优秀!