Okay, I’ve thought about this for a bit, and I think I know what I need to do to make this happen.
A lot of countdown scripts with internationalization have a separate JS file that “configures” this script. Which I guess is fine, if you have a pure JS solution, which this is not.
Since there’s a mixture of PHP and JS translations that need to happen, what I can do is generate a JS look-up table for certain localizations that have languages with multiple plurality.
So for Russian, I can look at the locale, and if it’s in Russian, generate a look-up table for the seconds/minutes. For 5 minutes, there’s just 5,4,3,2,1, and seconds (59-0). So for the default time, a look-up table for about roughly 64 instances.
Where it gets weird is I have a filter that allows a person to set the number of minutes of the countdown timer. To ease all sanity, I’m going to limit this to 90 minutes. 90 minutes in itself is a bit excessive, so I think anything above that will be limited.
This will limit the look-up table to (my apologies if my math is wrong), 90 (minute variables) and 59 (second variables).
I’ll save these as a transient every to expire every 24 hours for the explicit locale. All these variables might seem a bit much, but when minimized using JSON, won’t take up that much space. It’ll be more PHP processing, which is the reason for the transient.
When one of the locales is detected, I use the look-up table, if not, then regular minutes vs seconds is used.
I think this is the best short-term solution, and should have the least impact on backwards compatibility, and shouldn’t require the translator any significant extra effort besides using poedit to add all the pluralities (a word I discovered today).
I’ll try to have something testable this weekend on GitHub. If you’d like to help me test it, please let me know.