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

Support the reference symbol feature of i18n #150

Closed
tomoasleep opened this issue May 20, 2015 · 8 comments
Closed

Support the reference symbol feature of i18n #150

tomoasleep opened this issue May 20, 2015 · 8 comments
Milestone

Comments

@tomoasleep
Copy link
Contributor

The default backend (Backend::Simple) of i18n gem has a feature that allows you to specify translations as a reference to another key.

For example, the following YAML translation data is given:

en:
  sample: :foo.bar
  foo:
    bar:
      run:
        success: Success!

When you evaluate I18n.translate('.sample.run.success') it returns 'Success!'.
This is because that the backend interprets the symbol value :foo.bar corresponding to the key '.sample.run.success' as
the reference of another key '.foo.bar'.

Currently i18n-tasks gem does not support the feature and reports the use of such symbol references as missing keys.

If i18n-task gem will support this feature, I will send a PR :-)
What do you think?

Here's a reproducible example project:

@glebm
Copy link
Owner

glebm commented Aug 11, 2015

Hi, @tomoasleep! Apologies for the late reply! The goal of this project is to support as much of the i18n gem as possible, so I will merge a PR for this. 👍

@tomoasleep
Copy link
Contributor Author

@glebm Thanks for replying!
I'm busy now and I'm sorry that It would take time..., but I will send a PR 👍

@rstacruz
Copy link
Contributor

any kind soul want to offer doing this?

@glebm glebm added this to the v0.9.3 milestone Jan 27, 2016
@glebm
Copy link
Owner

glebm commented Jan 27, 2016

Basic requirements:

  1. Detect reference keys as unused if the target as unused.
  2. Detect reference keys as missing if the target is missing.
  3. Copy reference keys as is on add-missing and translate-missing.

@glebm
Copy link
Owner

glebm commented Jan 27, 2016

Update The basic design describe here turned out to be insufficient


A very basic design that doesn't give i18n-tasks full awareness of reference keys, meaning only basic reporting, but achieving all of the basic requirements above:

  1. Include all resolved references into used_key_names. What this means for the used references is:

    1. If a reference key is missing, it is reported as such.
    2. If a resolved.* key is missing, it is reported as such.
    3. Both reference and resolved are considered used.

    All unused references are also detected as unused.

    This achieves requirements (1) and (2).

  2. Hard-code reference check into add-missing and translate-missing to always copy as-is.

glebm added a commit that referenced this issue Jan 27, 2016
glebm added a commit that referenced this issue Jan 28, 2016
glebm added a commit that referenced this issue Jan 28, 2016
In theory, references should be somewhat supported for `find`, `missing`,
and `unused` at this point.

Missing support for `add-missing` and `translate-missing`, finding keys
by their resolved name via `find`, and nice reporting.
@glebm
Copy link
Owner

glebm commented Jan 28, 2016

In theory, references should be somewhat supported for find, missing, and unused at this point.

No support yet for: add-missing and translate-missing; finding keys by their resolved name via find; nice reporting.

If you need this feature, please try the version from the reference-keys branch and report here.

@glebm glebm mentioned this issue Jan 28, 2016
glebm added a commit that referenced this issue Jan 28, 2016
glebm added a commit that referenced this issue Jan 28, 2016
In theory, references should be somewhat supported for `find`, `missing`,
and `unused` at this point.

Missing support for `add-missing` and `translate-missing`, finding keys
by their resolved name via `find`, and nice reporting.
glebm added a commit that referenced this issue Jan 28, 2016
Also now highlights relative keys in the output.
@glebm
Copy link
Owner

glebm commented Jan 28, 2016

Keys can now be find by their resolved name via i18n-tasks find. Reporting also improved slightly.

@glebm
Copy link
Owner

glebm commented Feb 4, 2016

Released in v0.9.3.

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

No branches or pull requests

3 participants