Add fallback i18n if strings are missing from locale #26
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: miraty/libreqr#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "denisebitca/libreqr:intl_fallback_pr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On page load, at most three locales are loaded: user locale
from Accept-Language, the default locale (if they aren't the
same), and the template locale. Using function getIntlString(),
if the user locale doesn't have a string, the string is fetched
from the default locale (if they aren't the same), and then,
finally, if neither the user or the default locale have the string,
it is taken from the template (which only contains string labels).
Have you considered setting appropriate
lang
attributes? I think that would help screen readers in case of mixed language content.@miraty wrote in #26 (comment):
We could add a child tag in case of mixed language content. Something like data maybe?
Replacing
goto a;
with something like
...and so on and so forth, if necessary.
But could this idea be tested with a screen reader?
4e7b8bead0
doesn't break the CSS when it has to fallback. Requires screen reader testing, however.The
value
attribute is required for thedata
element according to the HTML Standard. I think you should just use aspan
element instead.I never tested anything with a screen reader, I just know that appropriately tagging the language is generally considered a good practice.
@miraty wrote in #26 (comment):
Okay, let's try using a span then.
getIntlString
returns HTML content but is sometimes used inside an HTML attribute, which is invalid. You should give up language taging in such cases, unless you find another solution.I didn't notice your placeholder hacks. Can you try using something like a boolean function argument to disable language taging instead? As I said on my previous message, there are other places where that will be a problem.
@miraty wrote in #26 (comment):
Sure, I'll add a parameter to set the format
@miraty wrote in #26 (comment):
I'm thinking of doing an argument with three possible values: html, attribute and raw.
What is the difference between attribute and raw?
@miraty wrote in #26 (comment):
I was going to say to add the lang attribute in placeholders, but I just checked, and placeholders are a visual element only. Nevermind, boolean it is.
You missed enabling the
raw
argument ongetIntlString('alt_QR_before')
andgetIntlString('alt_QR_after')
.There are unnecessary tabs on line 65 and end of line 68.
if
statements on line 55 and 57 can be merged.Also I think that could help with readability to invert the outer condition at the beginning of
getIntlString
, like so:If you don't have reasons to do this, consider using a consistent style for these points:
#
to comment instead of//
Everything else seems okay!
Should be good, you can go ahead and review @miraty :)
@ -31,0 +46,4 @@
function getIntlString(
$string_label,
$raw = false
){
Please use a space before the bracket
Done
@ -31,0 +35,4 @@
{
require "locales/" . DEFAULT_LOCALE . ".php";
$default_loc = $loc;
}
Still inconsistent brackets use in this block
Done
LGTM!!!! 🎊