Tag: 翻译

Gem Spree_i18n在服务器启动时抛出错误:无法加载翻译

的Gemfile: gem ‘spree’, ‘1.2.0’ #:git => ‘git://github.com/spree/spree.git’ gem ‘spree_auth_devise’, :git => ‘git://github.com/spree/spree_auth_devise’ # original repository not compatible at the moment, use fork # gem ‘spree_i18n’, :git => ‘git://github.com/spree/spree_i18n.git’ gem ‘spree_i18n’, :git => ‘git://github.com/kares/spree_i18n.git’ application.rb中: config.i18n.default_locale = :de Spree.rb :(初学者 ) Spree.config do |config| … config.default_locale = “de” end 还有什么: 我已将所有可能的语言yml文件复制到app / config / locale 我跑了“ […]

如何解决“无法批量分配受保护的属性:translations_attributes”错误?

我正在使用Ruby on Rails(3.2.2), globalize3 (0.2.0)和batch_translations (0.1.2)ruby-gems。 我想解决使用batch_translations ruby​​-gem时产生的以下问题: ActiveModel::MassAssignmentSecurity::Error in Admin::ArticlesController#update Can’t mass-assign protected attributes: translations_attributes 在我的ROOT_RAILS/Gemfile文件中,我有: … gem ‘globalize3’ gem ‘batch_translations’ 在我的ROOT_RAILS/app/models/admin/article.rb文件中,我有: class Admin::Article < ActiveRecord::Base translates :title # This is needed to make the batch_translations to work. accepts_nested_attributes_for :translations … end 在我的ROOT_RAILS/app/views/admin/articles/_form.html.erb文件中,我有: admin_article_path) do |f| %> English translation: Italiano translation: <% # Note: […]

在Rails 3中使用标记使整个文本国际化

Rails 3中的服务条款文档国际化的最佳实践是什么? 我可以想到两个选择: 为每个语言环境创建一个部分,并根据当前用户的语言环境选择要加载的语言环境。 这些似乎都不是一个好的解决方案。 有任何想法吗?

写入Rails中的响应? (就像PHP中的“echo”)

我知道我可以在Rails中做到这一点: 但有没有办法做到这一点 并让它出现在响应中?

如何动态地向I18n添加值?

我的rails应用程序中有很多ymls,我想将其中一些用于其他服务,以便我可以从多个地方调用它。 这个调用的响应将是一个哈希。 {“en” : {“test” : {“text1” : “hi english”}, {“text2” : “mambo number %{num}”} }, “es” : {“test” : {“text1” : “hi espaniol”}, {“text2” : “mamboes numeros %{num}”} } } 有没有办法可以将这个哈希加载到I18n翻译中 I18n.add_translations(some_hash) 所以我可以访问它们 I18n.t(“test.text1”) I18n.t(“test.text2”, :num => 5) 我怎么能实现它?

怎么写口译员?

我决定用Ruby编写一个小解释器作为我的下一个项目。 我需要什么样的知识/技能才能获得成功? 我还没有确定要解释的语言,但是我正在寻找一种不是玩具语言的东西,但是为它编写翻译会相对容易。 提前致谢。

为什么单词’translate’会弄乱irb?

我不明白为什么我的方法translate undefines start_with? 方法,并在irb中搞乱一些东西,所以我只能通过按Ctrl + d退出irb,而不是exit或quit : >> “hello”.respond_to?(:start_with?) => true >> def translate(string) >> if string.start_with?(“a”, “e”, “i”, “o”, “u”) >> string += “ay” >> end >> end NoMethodError: undefined method `start_with?’ for # from (irb):3:in `translate’ from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `’ >> “hello”.respond_to?(:start_with?) NoMethodError: undefined method `start_with?’ for :RubyVM::InstructionSequence from (irb):3:in `translate’ from /usr/local/rvm/rubies/ruby-2.3.0/bin/irb:11:in `’ […]