Feature #6548

Rake tasks to add/remove i18n strings

Added by Eric Davis about 7 years ago. Updated about 7 years ago.

Status:ClosedStart date:2010-09-30
Priority:NormalDue date:
Assignee:Eric Davis% Done:

100%

Category:Translations
Target version:1.0.3
Resolution:Fixed

Description

It would help with i18n if there were two more rake tasks:

  • one to add a new string rake locales:add key=text_a_new_string value="Default value"
  • one to remove a string rake locales:remove key=text_an_old_string

It would be even better if it could be used to exclude specific locales like "exclude=en". This can be used to invalidate translated strings if the content is going to change.

Associated revisions

Revision 4254
Added by Eric Davis about 7 years ago

Add rake tasks to add and remove keys in the locales. #6548

Contributed by Felix Schäfer

History

#2 Updated by Eric Davis about 7 years ago

  • Assignee changed from Felix Schäfer to Eric Davis

#3 Updated by Eric Davis about 7 years ago

  • Assignee changed from Eric Davis to Felix Schäfer

remove_key isn't working. I'm editing a string and wanted to remove all translated strings so they can be retranslated.

$ r locales:remove_key key=field_member_of_group skip=en
(in /home/edavis/dev/redmine/redmine-core)
Deleting selected keys from ./config/locales/mk.yml
Deleting selected keys from ./config/locales/sr.yml
Deleting selected keys from ./config/locales/ja.yml
Skipping ./config/locales/en.yml
Deleting selected keys from ./config/locales/fi.yml
Deleting selected keys from ./config/locales/zh.yml
Deleting selected keys from ./config/locales/ko.yml
Deleting selected keys from ./config/locales/bs.yml
Deleting selected keys from ./config/locales/hu.yml
Deleting selected keys from ./config/locales/pt-BR.yml
Deleting selected keys from ./config/locales/es.yml
Deleting selected keys from ./config/locales/gl.yml
Deleting selected keys from ./config/locales/zh-TW.yml
Deleting selected keys from ./config/locales/pl.yml
Deleting selected keys from ./config/locales/sv.yml
Deleting selected keys from ./config/locales/sl.yml
Deleting selected keys from ./config/locales/th.yml
Deleting selected keys from ./config/locales/fr.yml
Deleting selected keys from ./config/locales/uk.yml
Deleting selected keys from ./config/locales/id.yml
Deleting selected keys from ./config/locales/de.yml
Deleting selected keys from ./config/locales/bg.yml
Deleting selected keys from ./config/locales/sr-YU.yml
Deleting selected keys from ./config/locales/lv.yml
Deleting selected keys from ./config/locales/nl.yml
Deleting selected keys from ./config/locales/tr.yml
Deleting selected keys from ./config/locales/he.yml
Deleting selected keys from ./config/locales/pt.yml
Deleting selected keys from ./config/locales/it.yml
Deleting selected keys from ./config/locales/vi.yml
Deleting selected keys from ./config/locales/ca.yml
Deleting selected keys from ./config/locales/el.yml
Deleting selected keys from ./config/locales/ru.yml
Skipping ./config/locales/en-GB.yml
Deleting selected keys from ./config/locales/da.yml
Deleting selected keys from ./config/locales/eu.yml
Deleting selected keys from ./config/locales/lt.yml
Deleting selected keys from ./config/locales/hr.yml
Deleting selected keys from ./config/locales/sk.yml
Deleting selected keys from ./config/locales/mn.yml
Deleting selected keys from ./config/locales/cs.yml
Deleting selected keys from ./config/locales/ro.yml
Deleting selected keys from ./config/locales/no.yml

$ git diff
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8b2a9c9..616b672 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -293,8 +293,8 @@ en:
   field_group_by: Group results by
   field_sharing: Sharing
   field_parent_issue: Parent task
-  field_member_of_group: Member of Group
-  field_assigned_to_role: Member of Role
+  field_member_of_group: Assignee is a member of group
+  field_assigned_to_role: Assignee is a member of role
   field_text: Text field

   setting_app_title: Application title

Notice that git diff isn't showing any changes other than my manual edits to en.yml.

#4 Updated by Felix Schäfer about 7 years ago

Eric Davis wrote:

remove_key isn't working.

I'm so sure I tried it before committing it… Anyway, corrected version is up on the githubs, the diff is quite short though:

diff --git a/lib/tasks/locales.rake b/lib/tasks/locales.rake
index fb7de6e..5125384 100644
--- a/lib/tasks/locales.rake
+++ b/lib/tasks/locales.rake
@@ -50,7 +50,7 @@ END_DESC
       (puts "Skipping #{path}"; next) if File.basename(path, ".yml") =~ skips
       puts "Deleting selected keys from #{path}" 
       orig_content = File.open(path, 'r') {|file| file.read}
-      File.open(path, 'w') {|file| orig_content.each_line {|line| file.puts line unless line =~ delete_regex}}
+      File.open(path, 'w') {|file| orig_content.each_line {|line| file.puts line unless line.chomp =~ delete_regex}}
     end
   end
   

#5 Updated by Felix Schäfer about 7 years ago

  • Assignee changed from Felix Schäfer to Eric Davis

(and please remember to remove the "wrong"-in-everything-but-english label_user_mail_option_none, thanks)

#6 Updated by Eric Davis about 7 years ago

  • Status changed from 7 to Resolved
  • Target version changed from Unplanned to 1.0.3
  • % Done changed from 0 to 100
  • Resolution set to Fixed

Thanks for the fix Felix, committed in r4254.

(and please remember to remove the "wrong"-in-everything-but-english label_user_mail_option_none, thanks)

Committed in r4255.

#7 Updated by Eric Davis about 7 years ago

  • Status changed from Resolved to Closed

Merged into 1.0-stable for release in 1.0.3

Also available in: Atom PDF