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 for ignore some 'unused' keys #22

Open
Gotusso opened this issue May 13, 2014 · 6 comments
Open

Support for ignore some 'unused' keys #22

Gotusso opened this issue May 13, 2014 · 6 comments
Assignees

Comments

@Gotusso
Copy link

Gotusso commented May 13, 2014

In our project sometimes we need to generate translation keys by concatenating strings.
If we don't use the option 'safeMode', those keys are removed.
The problem is that if we use it, those keys remains untouched but the unused keys (generated by typos or just not used) are not removed.

It would be really nice to have an option to avoid the removal of the 'unused' keys from a specific module, while keeping the behavior for the remaining modules untouched.

@firehist
Copy link
Member

Hey @Gotusso
If I well got it, you want run extraction without delete existing keys into you json ?
The safeMode doesnt delete unused keys and doesnt update "valid" keys so I'll add an keepExtra option to update existing keys from extraction and keep extra keys in json file!

@Gotusso
Copy link
Author

Gotusso commented May 26, 2014

Sorry, I'm not sure about what do you mean with "update" keys. My use case is more o less this:

Javascript:

// Get some value from the server
var backendValue = 'bar'; 
// Get the translation and use it somewhere
$translate('foo.' + backendValue).then(function(value) {
    // ...
});
// 'fo' is a typo
$translate('fo.' + backendValue).then(function(value) {
    // ...
});

JSON before running the grunt task:

{
    "foo": {
        "bar": "Hello world!"
    },
    "bar": {
        "baz": "Unused translation"
    }
}

Expected JSON after running the grunt task:

{
    "foo": {
        "bar": "Hello world!"
    }
}

So I'm thinking about a configuration like this:

{
            namespace: true,
            safeMode: false,
            keepExtra: [
                'foo.**'
            ]
        }

And with that, the task could know that it must keep everything inside foo translations and work as usual for the rest.
What do you think?

@firehist
Copy link
Member

firehist commented Sep 5, 2014

If I well understand, you want ignore some pattern key to be able to write them down manually ?

@Gotusso
Copy link
Author

Gotusso commented Sep 10, 2014

Exactly

@firehist
Copy link
Member

Okay @Gotusso i'll try to do the job

@firehist firehist self-assigned this Sep 10, 2014
@Gotusso
Copy link
Author

Gotusso commented Sep 10, 2014

Thanks!

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

2 participants