RubyMine RoR I18n config / locals / en.yml语法错误“文件应该有单根”

时间:2014-05-10 18:26:56

标签: ruby ruby-on-rails-4 yaml rubymine i18n-gem

我不知道这是不是一个粗俗的语法错误,或者这是我应该合理关注的事情。我在网上搜索了这个错误,发现很少有人关注它。所以我的猜测是,要么是这样的“没有duh”,几乎没有人会因为这个错误而结束,或者它是如此模糊不清 - 再次 - 几乎没有人最终得到它。尽管如此,我们走了: 这就是我正在使用的: Ruby 2.1.1p76 Rails 4.0.5 SafeYAML 1.0.3 RubyMine 6.3 [如果您需要更多信息,请询问]

我得到的错误是:“Rails i18n语言环境文件应该有单根”

这是我的en.yml文件的缩短版本(我将包括我认为的问题区域)

    <%
      object_names = **{**   
        :administrator => 'Administrator',
        :activity_log => 'Site Activity',
        :answer => 'Answer',
        :approval => 'Approval',
        :user => 'Member',
        :video => 'Video',
        :vote => 'Like'
      }

      section_names = **{**
        :approvals => 'Items Awaiting Review',
        :advertisements => 'Advertisements',
        :ad_placements => 'Ad Placements',
        :awarded_badges => 'Badges',
        :badges => 'Badges',
        :videos => 'Videos'
      }

      anonymous = 'Anonymous**'
    %>

    en:
      homepage:
        mine: "My %{site_name}"
      site_name: "%{site_name}"
      site_condition_name: "%{site_condition_name}"

      titles:
        main: "%{site_name}"
        delimiters:
          minor:** ' **-** '
          major: ' | '
        scopes:
          popular: Popular
          newest: Newest
          active: Active

          my_feed: My Friends
          my_activity: What I've Done
          tracked_items: "Only <%= object_names[:tracked_item].pluralize %>"
          everyone: Everyone

          user: "By %{name}"
          view: "By %{view}"
          sent: "Sent <%= object_names[:message].pluralize %>"
          page: "Page %{page}"
          letter: "Starting With %{letter}"
          query: "%{query}"
          category: "%{category}"

      **meta_description:**
        main: "%{site_name} is a social network that connects people"

      footer:
        about: "About %{site_name}"
        about_alliance_health: About Alliance Health
        community_advocates: Community Advocates
        terms_of_use: Terms of Use
哦,哇。好吧,看起来粗体不会在代码标记内部起作用。但我相信你们可以破译正在发生的事情。基本上任何粗体(或用双星号'**'分隔)都是IDE用这个特殊错误标记代码的地方。所以,正如你所看到的,它似乎相当混乱和荒谬。但是我经常发现,当这样的事情发生时,它通常是一个小小的角色,在其他地方抛弃其他东西。

现在,我不是YAML专家 - 事实上,我几乎不知道这些东西(这是我计划在不久的将来改变的东西),所以这可能是“没有duh”线的东西。然而,值得注意的是,错误标记语法的大部分都是从单词的最后一个单引号开始:“'anonymous'”,一直到:“minor:”,跳过第一个单引号,并在连字符上再次拾起,之后该文件的近5500行的其余部分没有更多错误。

感谢任何帮助过的人。我已经花费了很长时间,并且很少有关于这个特定问题的在线信息。所以任何帮助都非常感谢:)

谢谢!

1 个答案:

答案 0 :(得分:0)

所以 - 我不确定这会对任何人有所帮助......但在可能的情况下,这就是我重新设计脚本以避免错误的方式。我只是删除了导致解析混乱的常用分隔符。 @mu太短了,你是对的。这是一个erb.yml文件,虽然我不确定为什么原始创建者离开了双扩展。无论如何 - 感谢所有提出任何建议和想法的人:)

<%
  object_names = Hash.new
  object_names[:administrator] = %q<Administrator>
  object_names[:activity_log] = %q<Site Activity>
  object_names[:answer] = %q<Answer>
  object_names[:approval] = %q<Approval>
  object_names[:user] = %q<Member>
  object_names[:video] = %q<Video>
  object_names[:vote] = %q<Like>

  section_names = Hash.new
  section_names[:approvals] = %q<Items Awaiting Review>
  section_names[:advertisements] = %q<Advertisements>
  section_names[:ad_placements] = %q<Ad Placements>
  section_names[:awarded_badges] = %q<Badges>
  section_names[:badges] = %q<Badges>
  section_names[:videos] = %q<Videos>
%>

en:
  homepage:
    mine: "My %{site_name}"
  site_name: "%{site_name}"
  site_condition_name: "%{site_condition_name}"

  titles:
    main: "%{site_name}"
    delimiters:
      minor: ' - '
      major: ' | '
    scopes:
      popular: Popular
      newest: Newest
      active: Active

      my_feed: My Friends
      my_activity: What I've Done
      tracked_items: "Only <%= object_names[:tracked_item].pluralize %>"
      everyone: Everyone

      user: "By %{name}"
      view: "By %{view}"
      sent: "Sent <%= object_names[:message].pluralize %>"
      page: "Page %{page}"
      letter: "Starting With %{letter}"
      query: "%{query}"
      category: "%{category}"

  meta_description:
    main: "%{site_name} is a social network that connects people"

  footer:
    about: "About %{site_name}"
    about_alliance_health: About Alliance Health
    community_advocates: Community Advocates
    terms_of_use: Terms of Use