azuyalabs / yasumi

The easy PHP Library for calculating holidays
https://www.yasumi.dev
Other
1.05k stars 155 forks source link

Common translation #5

Closed Furgas closed 9 years ago

Furgas commented 9 years ago

I'm adding Polish provider, and I think that it would be nice to have some global translation table in form of shortName => [locale => transaltion, locale => translation, ...] that will be used if no translation is provided in Holiday constructor. What do you think?

stelgenhof commented 9 years ago

Absolutely! Since Yasumi is in it's early stage, I decided first to put in the constructor. However that's not really flexible :). Let me think about how to do the translations.

stelgenhof commented 9 years ago

@Furgas I have been looking into the translation and there are some considerations here. First of all, since holidays are loaded dynamically, it would mean translations have to be reloaded if a new holiday (with its translations) is added. That might not benefit performance, also because currently you can add holidays at runtime. One way to avoid that is to disable the adding of holidays runtime (i.e. make 'addHoliday' not a public method).

Secondly, the structure of the translation files. We can have all translations in a single file representing a locale, or a single file per holiday containing all translations of one or more locales. I tend to have a single locale file (e.g. 'en_US', 'de_DE') for translation purposes (when a translator is doing one language). However, performance could be an issue here as well as all files need to be processed.

What do you think.?