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

Doesn't work with locale as directory #176

Closed
Silex opened this issue Nov 2, 2015 · 8 comments
Closed

Doesn't work with locale as directory #176

Silex opened this issue Nov 2, 2015 · 8 comments
Labels
Milestone

Comments

@Silex
Copy link

Silex commented Nov 2, 2015

Hello,

The following structure doesn't seem to work (my en locale gets overwritten with the fr one):

base_locale: en
locales: [fr]
data:
  read:
    - config/locales/%{locale}/*.yml
  write:
    - ['{:}.*', 'config/locales/%{locale}/\1.yml']

Maybe related to #14

This happens when I do i18n-tasks add-missing

@Silex
Copy link
Author

Silex commented Nov 2, 2015

Ah, I just found it's because I was missing

  router: pattern_router

Maybe this should be better documented?

glebm added a commit that referenced this issue Nov 3, 2015
@glebm
Copy link
Owner

glebm commented Nov 3, 2015

Hi, I've added a note about that and the alternative option to the Readme. Looks good?

@glebm glebm closed this as completed Nov 3, 2015
@glebm glebm added the docs label Nov 3, 2015
@Silex
Copy link
Author

Silex commented Nov 3, 2015

Yes it's better but, the following is unexpected:

or run `i18n-tasks normalize -p` (forcing the use of the pattern router for that run)

does normalize calls add-missing?

The problem I had is that config/locales/\1.%{locale}.yml worked correctly, but when I simply changed that for config/locales/%{locale}/\1.yml then it didn't work when using add-missing.

@glebm glebm added bug and removed docs labels Nov 3, 2015
@glebm
Copy link
Owner

glebm commented Nov 3, 2015

I missed the part in your original post that said:

my en locale gets overwritten with the fr one

There is a bug in the conservative router here, where it does locale replacement for the matched path. The way it does it is brittle, but it can be easily modified to match /locale/ and locale/ as well (as opposed to just .locale. and locale.).

@glebm glebm reopened this Nov 3, 2015
glebm added a commit that referenced this issue Nov 3, 2015
This is super brittle and needs to be improved eventually.
Refs #176
@glebm glebm added this to the v0.9.2 milestone Nov 3, 2015
@glebm
Copy link
Owner

glebm commented Nov 3, 2015

I've attempted to fix this above. Does the master branch work for you?

@glebm glebm closed this as completed Nov 3, 2015
@connorshea
Copy link

@glebm thanks for working on this, I've been having the same problem. Would it be possible for you to release a beta version of the gem to rubygems.org so I can test to see if this fixes it?

@Silex
Copy link
Author

Silex commented Nov 4, 2015

I'm in a rush at work, so I won't be able to test this before the end of the week... but it looks good.

@glebm
Copy link
Owner

glebm commented Nov 4, 2015

@connorshea You can test with:

gem 'i18n-tasks', git: 'https://github.com/glebm/i18n-tasks'

bartimaeus added a commit to bartimaeus/i18n-tasks that referenced this issue Dec 7, 2015
* upstream/master: (70 commits)
  Readme: bump version
  Bump to 0.9.2
  Fix ActiveSupport >= 4.0, < 4.2 compat
  Added note to README to stop anyone else wasting an hour of their time.
  Replace multiple instances of %{locale} in path
  Match %{locale}/ for path locale replacement
  Readme: a note on the routers glebm#176
  Bump to 0.9.1
  I18n::Tasks.add_scanner, I18n::Tasks.add_commands
  Trivial refactoring in used_keys.rb
  Revert "ActiveSupport < 4 compat"
  Fix bin/18n-tasks tests on travis
  Only match I18n or nil receivers in PatternScanner
  Add required_ruby_version to gemspec
  Bump to 0.9.0
  Remove WIP temple scanner classes
  AST Scanner: fix magic comment location reporting
  Use AST::Sexp helpers instead of AST::Node.new
  travis: Test on Ruby 2.2.3 (was 2.2.2)
  Depend on ast 2.1.0+.
  ...
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