Skip to content

Commit

Permalink
Move locales to separate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
krasnoukhov committed Feb 22, 2014
1 parent 98bd454 commit b0dc1de
Show file tree
Hide file tree
Showing 24 changed files with 15 additions and 13 deletions.
22 changes: 12 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace :i18n do
desc "Invalidate locales one-by-one"
task :invalidate do
available = Dir.glob("*.yml").map { |x| x.chomp(".yml").to_sym }
base = :en
translations = available - [base]
master = :en
basedir = File.join(Dir.pwd, "locales")
available = Dir.glob(File.join(basedir, "*.yml"))
translations = available - [master]
identation = " " # ._.

while true
Expand All @@ -13,11 +14,12 @@ namespace :i18n do

confirm = []
results = Hash.new
translations.each do |locale|
lines = File.read("#{locale}.yml").split("\n")
translations.each do |translation|
locale = File.basename(translation, ".yml")
lines = File.read(translation).split("\n")
result = Hash.new
level = 0
full_path = [locale.to_s] + path.split(".")
full_path = [locale] + path.split(".")

lines.each_with_index do |text, line|
current_identation = " "*level
Expand Down Expand Up @@ -55,17 +57,17 @@ namespace :i18n do

confirm << "#{locale}.yml:#{multiline ? "#{result[:lines].first+1}..#{result[:lines].last+1}" : result[:lines].first+1}"
confirm << (multiline ? "\n#{result[:texts].join("\n")}\n\n" : " - #{result[:texts].first.strip}\n")
results[locale] = result
results[translation] = result
end
end

if confirm.any?
puts confirm.join(""), "\n", "Confirm? y/n"
if STDIN.gets.strip == "y"
results.each do |locale, result|
lines = File.read("#{locale}.yml").split("\n")
results.each do |translation, result|
lines = File.read(translation).split("\n")
result[:lines].each { |x| lines[x] = nil }
File.open("#{locale}.yml", "w") { |f| f.write(lines.compact.join("\n")+"\n") }
File.open(translation, "w") { |f| f.write(lines.compact.join("\n")+"\n") }
end

puts "Done."
Expand Down
2 changes: 1 addition & 1 deletion checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""

master = "en"
basedir = "%s/locales" % os.getcwd()

def compare_dicts(master, victim, path):
if type(victim) != dict:
Expand Down Expand Up @@ -70,7 +71,6 @@ def process_file(filename, master_data):

def main(args):
exitcode = 0
basedir = os.path.dirname(__file__) or '.'
with open(os.path.join(basedir, "%s.yml" % master), 'r') as master_file:
master_data = yaml.load(master_file)[master]

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions zh-cn.yml → locales/zh-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ zh-cn:
unlock_instructions:
subject: "帐户解锁"

# Reader
app: "The Old Reader"
# Reader
app: "The Old Reader"
eggs: "We ♥ kittens"
title: "The Old Reader"
meta:
Expand Down
File renamed without changes.

0 comments on commit b0dc1de

Please sign in to comment.