Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing issue #20

Open
zyphlar opened this issue Mar 21, 2013 · 8 comments
Open

Parsing issue #20

zyphlar opened this issue Mar 21, 2013 · 8 comments
Labels

Comments

@zyphlar
Copy link
Contributor

zyphlar commented Mar 21, 2013

Unknown why i15r had issues with this line. Maybe it's because of the custom form generator we're using that provides a :label attribute? A very interesting failure mode.

-<%= f.text_field :feature_list, :size=>60, :label=>'Feature flags', :append=>' (space separated)', :help=>"Known: #{@features.join(', ')}" %>
+<%= f.text_field :feature_list, :size=>60, :label=>I18n.t("admin.accounts.form.feature_flags_append=>space_separated_help=>known{@featuresjoin_", :default => 'Feature flags', :append=>' (space separated)', :help=>"Known: #{@features.join(', '))}" %>

-<%= f.text_field :account_id, :label=>'Account ID', :size=>12, :readonly=>true, :clear=>false %>
+<%= f.text_field :account_id, :label=>'Account ID', I18n.t("admin.guests.form.size", :default => "size")=>12, :readonly=>true, :clear=>false %>

-<%= f.text_field :cluster_name, :label=>'Location', :size=>12, :readonly=>true %>
+<%= f.text_field :cluster_name, :label=>'Location', I18n.t("admin.guests.form.size", :default => "size")=>12, :readonly=>true %>

@zyphlar
Copy link
Contributor Author

zyphlar commented Mar 21, 2013

Also (probably because of the <%= label %> syntax)

-<%= label nil, :new_host_id, 'New host' %>
+<%= label nil, I18n.t("admin.guests.relocate.new_host_id", :default => "new_host_id"), 'New host' %>

@zyphlar
Copy link
Contributor Author

zyphlar commented Mar 21, 2013

This one is interesting. It seems to have keyed in on the plaintext "qux" but then symbolized the first AND second instances of "qux."

-<%=h foo.foo_bar %>; <%=h foo.foo_baz %>; <%=h foo.foo_quxes %>qux
+<%=h foo.foo_bar %>; <%=h foo.foo_baz %>; <%=h foo.<%= I18n.t("admin.foo.index.qux", :default => "qux") %>es %><%= I18n.t("admin.foo.index.qux", :default => "qux") %>

@zyphlar
Copy link
Contributor Author

zyphlar commented Mar 21, 2013

And another. Maybe some kind of catchall or <br> detection?

       <%= show(@plan, :subscription_options) do |p|
         p.subscription_options.map do |so|
           "#{pluralize so[:interval], 'month'}: #{number_to_currency so[:cost]}"
-        end.join('<br />')
+        <%= I18n.t("admin.plans.show.endjoin", :default => "end.join('") %><br />')
       end %>

@zyphlar
Copy link
Contributor Author

zyphlar commented Mar 21, 2013

Don't mind me, just documenting interesting stuff I find :) I understand the 80/20 rule.

-<%= [:notice, :warning, :error].collect {|f| "<div class=\"messaging #{f}\">#{h flash[f]}</div>\n" if flash[f] }.compact.join %>
+<%= [:notice, :warning, :error].collect {|f| "<div class=\"messaging #{f}\"><%= I18n.t("foo.bar.{h_flash[f]}", :default => "#{h flash[f]}") %></div>\n" if flash[f] }.compact.join %>

[brackets] and other symbols aren't valid yml

<td colspan="2">&nbsp;</td>
<td colspan="2"><%= I18n.t("foo.bar.&nbsp", :default => "&nbsp;") %></td>
<%= link_to '[admin]', :controller=>'/admin' %>
<%= link_to I18n.t("foo.bar.[admin]", :default => '[admin]'), :controller=>'/admin' %>

@Arpsara
Copy link

Arpsara commented Jan 29, 2014

Hi ! :) Thank you for this very useful gem ! Here is some other bug that concerns strings that should not have been replaced or ones that have been replaced incorrectly. (Actually, it's the same than zyphlar.)

It seems that if there are some code after the :label => " ", the remplacement fails.

In a form with semantic_form_for :

<%= f.input :email, :as => :email, :label => false, :input_html => { :placeholder => "Votre mail" } %>  
<%= f.input :email, :as => :email, :label => false, I18n.t("pages.contact.input_html") => { :placeholder => "Votre mail" } %>
<%= f.action :submit, :label =>"Envoyer", :button_html => {:class => "button"} %>
<%= f.action :submit, :label =>I18n.t("pages.contact.envoyer_button_html_=>_{class_=>_", :default => "Envoyer", :button_html => {:class => ")button"} %>

@Arpsara
Copy link

Arpsara commented Jan 29, 2014

Here is some others bugs :

<%= link_to "Editer l'article", edit_admin_article_path(@article) %>
<%= link_to I18n.t("articles.show.editer_l")article", edit_admin_article_path(@article) %>

It doesn't seem to like the ' . :)

@zyphlar
Copy link
Contributor Author

zyphlar commented Jan 29, 2014

Is there some way we can parse ERB just like Rails does, rather than trying
to use Regex to parse? I think we'll always run into issues as long as we
use regex.
On Jan 29, 2014 2:54 AM, "Arpsara" [email protected] wrote:

Here is some others bugs :

'''
<%= link_to "Editer l'article", edit_admin_article_path(@articlehttps://github.com/article)
%>
<%= link_to I18n.t("articles.show.editer_l")article",
edit_admin_article_path(@Article https://github.com/article) %>
'''
It doesn't seem to like the ' . :)

Reply to this email directly or view it on GitHubhttps://github.com//issues/20#issuecomment-33570109
.

@EddieDee
Copy link

Same thing happening to me, trying to figure it out with http://rubular.com, but Regex is hard haha this guy is awesome, will be cool to add type of strings to the reserve words

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants