zendframework / zend-i18n

I18n component from Zend Framework
BSD 3-Clause "New" or "Revised" License
65 stars 49 forks source link

Add getCacheId method to Translator #63

Closed mlocati closed 6 years ago

mlocati commented 7 years ago

What about adding a getCacheId method to get the ID of the cache item?

That would be useful when subclassing Translator(for instance, we'd need a cache ID that depends on the contents of the $files, $patterns and $remote properties).

weierophinney commented 6 years ago

I'm afraid I don't understand the use case: what would this enable, exactly? You mention it would be useful for subclasses of Translator, but now how...

MatthiasKuehneEllerhold commented 6 years ago

We have translation that are changing during the run time of our app and we need to invalidate the translation-cache to trigger a reload of the underlying translation providers.

Therefor I'd like to propose adding this function and marking it public.

Better yet: a function that clears the cache of a specific text domain / language.

MatthiasKuehneEllerhold commented 6 years ago

I'm not sure if @mlocati is active on gh anymore that's why I've added a PR with my proposal based upon his PR. Sorry if I'm stealing your thunder!

mlocati commented 6 years ago

I'm afraid I don't understand the use case: what would this enable, exactly? You mention it would be useful for subclasses of Translator, but now how...

@weierophinney I absolutely can't remember why we needed this (there has been a lot of water under the bridge...), but I guess we needed something like @MatthiasKuehneEllerhold wrote above (and we solved in another way because of lack of activity of ZF).

I'm not sure if @mlocati is active on gh anymore

@MatthiasKuehneEllerhold Sure: loot at how green is my GitHub wall :wink:

that's why I've added a PR with my proposal based upon his PR. Sorry if I'm stealing your thunder!

No problems at all! I'm closing this #63 in flavor of #93.