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

Missing replacements #17

Open
BjoernKW opened this issue Feb 7, 2013 · 3 comments
Open

Missing replacements #17

BjoernKW opened this issue Feb 7, 2013 · 3 comments

Comments

@BjoernKW
Copy link

BjoernKW commented Feb 7, 2013

Lines like the following ones (taken from scaffolded Rails artefacts) aren't properly replaced when running 'i15r .' from a Rails app root directory:

Controller 'create' action:
format.html { redirect_to @Company, notice: 'Company was successfully created.' }

Controller 'update' action:
format.html { redirect_to @Company, notice: 'Company was successfully updated.' }

index.html.erb view:
<%= link_to I18n.t("companies.index.destroy"), company, method: :delete, data: { confirm: 'Are you sure?' } %>

@balinterdi
Copy link
Owner

Okay, so there are reasons why these lines are not considered for internationalization. Let's see if they are good ones :)

First, i15r will only change strings in views, more precisely anything ending in .erb or .haml. So that's why nothing was changed in the controller examples. It would be possible to do controllers, but I want to keep the code simple and I think this would introduce complexity for gaining too little (strings to be internationalized in controller and model code are few, and other issues, like generating the message key prefix from the file name, would crop up).

In the case of the index view, it is not changed because only one string is replaced in each line and if a line already has I18n.t in it than it will not be touched. Again, this is in line with the 80-20 idea and keeps the regular expressions in check and the code simple.

That said, I'd love to hear your opinion on all this.

@BjoernKW
Copy link
Author

BjoernKW commented Feb 8, 2013

While I understand your design decisions I think i15r should at least attempt to cover every possible string occurrence in views as otherwise the user might be confused or miss some translatable string altogether.

@balinterdi
Copy link
Owner

Hmm, good point. What you're saying is that i15r should follow the principle of least surprise and replace all occurrences of plain strings in views.

I think it (replacing several strings on the same line) can be done. The bad news is that it probably makes necessary a major overhaul of the current design. Let me dwell on this a bit more. Thank you for your feedback.

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

No branches or pull requests

2 participants