-
Notifications
You must be signed in to change notification settings - Fork 22
Add support for yml filenames where locale is used as prefix #22
base: master
Are you sure you want to change the base?
Conversation
Any thoughts about this? I don't want to annoy anyone, but please don't leave a small and focused PR hanging like this 😉 |
dee1b40
to
dd4cf0c
Compare
# this just replaces the locale part of the file name | ||
path = translation.file | ||
.sub(/(\/|\.)#{translation.locale}\.yml$/, "\\1#{locale}.yml") | ||
.sub(/\/#{translation.locale}([^\/]+)\.yml$/, "/#{locale}\\1.yml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find these regexes really tough to read, when what we're trying to do is remove the -2
constant. How about:
parts = File.basename(translation.file).split('.')
parts[parts.index(translation.locale)] = locale
path = "#{File.dirname(translation.file)/#{parts.join('.')}"
😁
@1st8 Ha, had that coming 😄 |
af4ab30
to
e243cd3
Compare
Extract path transformation helper #replace_locale_in_path
e243cd3
to
af0e334
Compare
@kaspth Hehe, yeah 😉 |
@store.create_missing_keys | ||
|
||
assert_equal(1, calls.count) | ||
assert_equal(['da', 'en', '/tmp/da.yml'], calls.first) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see the point in testing argument positions, sounds like a bag of hurt going forward 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am testing, that the interface defined by Transformation. replace_locale_in_path
is used and used correctly. Otherwise I can't be sure, that it is actually used and not being replaced with something inline, which would make my encapsulated tests obsolete.
Coming along nicely 👍 |
No description provided.