Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails i18n API的Yaml翻译文件中的复数形式示例_Ruby On Rails_Internationalization_Yaml_Gettext - Fatal编程技术网

Ruby on rails Rails i18n API的Yaml翻译文件中的复数形式示例

Ruby on rails Rails i18n API的Yaml翻译文件中的复数形式示例,ruby-on-rails,internationalization,yaml,gettext,Ruby On Rails,Internationalization,Yaml,Gettext,有人能提供一个关于如何在Rails i18n API的Yaml翻译文件中使用复数形式的示例吗。基本上,这是关于从基于gettext的应用程序转移到Rails 此处记录了Rails中a18n的复数形式,但细节有限 例如,我从一个使用复数形式的gettext.po文件中获得了这个示例: msgid "found %d fatal error" msgid_plural "found %d fatal errors" msgstr[0] "s'ha trobat %d error fatal" msg

有人能提供一个关于如何在Rails i18n API的Yaml翻译文件中使用复数形式的示例吗。基本上,这是关于从基于gettext的应用程序转移到Rails

此处记录了Rails中a18n的复数形式,但细节有限

例如,我从一个使用复数形式的gettext.po文件中获得了这个示例:

msgid "found %d fatal error"
msgid_plural "found %d fatal errors"
msgstr[0] "s'ha trobat %d error fatal"
msgstr[1] "s'han trobat %d errors fatals"
在Rails i18napi的.yml文件中会是什么样子。我知道Rails i18n使用唯一的id键,而不是消息本身作为翻译键——所以让我们假设上面的复数消息的键是find_x_fatal_error

另一件事是复数形式的选择公式,它在.yml文件中的位置以及它的外观-例如,我们有一个gettext.po文件头中的选择公式:

Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;

它在YAML文件中的外观如何。

您可以配置更多选项:

error_msg:
  zero: none
  one: 1 error
  other: %{count} errors

t('error_msg', :count => 15)
=> 15 errors
根据I18n的版本,它将在yml文件中为{count}或%{count}。更多说明可在此处找到:


我认为这条线索可能会帮助您: