Skip to content

Allow prefix to be an array to search in multiple places#53

Open
jurienhamaker wants to merge 5 commits intogilsdav:masterfrom
jurienhamaker:feature/multi-prefix
Open

Allow prefix to be an array to search in multiple places#53
jurienhamaker wants to merge 5 commits intogilsdav:masterfrom
jurienhamaker:feature/multi-prefix

Conversation

@jurienhamaker
Copy link

For the application I am working on I need multiple types of values to be translated. To keep order in my translations file. I'd like to use multiple prefixes to search in different places for my translation.

Example (dutch);

{
    "routes": {
         "about": "over-ons"
     },
     "categories": {
         "bananas": "bananen"
     }
}

When prefixes set to ["routes.", "categories."] I will allow the translate parser to search for both predefined routes & categories.

@jurienhamaker jurienhamaker requested a review from gilsdav January 16, 2020 09:14
@gilsdav
Copy link
Owner

gilsdav commented Jan 18, 2020

Hello @jurienhamaker, Thank you for your PR.
If I undersand you don't want to use sub keys like :

{
    "routes": {
         "about": "over-ons",
         "categories": {
             "bananas": "bananen"
        }
     }
}

What you want the library do if it find multiple values ? (Actually you PR stop to first one)

{
    "routes": {
         "about": "over-ons"
     }
    "categories": {
         "about": "bananen"
    }
}

I think it will open the door to multiple usage mistake.

@jurienhamaker
Copy link
Author

I use the data for such categories for multiple things (not just routes), it would be a very easy mistake to update one value and forget the other if we we're to ever change the values.

For that purpose we want one source of truth for those translations.

I am not sure what I would want the library to do if there are multiple values. I could warn the user that multiple entries were found (and not break) and use the first one., but that would also be an issue to performance (iterating more than you have to).

@gilsdav
Copy link
Owner

gilsdav commented Jan 29, 2020

Alright, I will merge this soon.
What Angular version do you actually use ?

@jurienhamaker
Copy link
Author

Latest stable.

@gilsdav gilsdav requested a review from Poizo February 12, 2021 20:42
@gilsdav gilsdav added the enhancement New feature or request label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants