Open DavidKrassnig opened 1 year ago
Caveat: The first_name, middle_name, and last_name variables in _config.yml are still required for checking whether or not a value for each category exists (checking with the localized variants doesn't work for me for some reason).
This means that you would have to have a first/middle/last name in each localized language if (and only if) you have one set in __config.yml (otherwise a superfluous non-breaking character is added in the header).
Otherwise, the implementation works fine for me (displayed text and metadata).
Good point, in some languages the names might be used in a different order/different charset. Do you think maybe a solution like I implemented in date_format fits better?
Hm. Yes, I hadn't really considered the issue of different order (my required case followed the same order). That would require an edit along the lines of your date_format, as you suggested. Perhaps an if-clause that switches the display of first_name
and last_name
for all language ISO codes that are known to do that? That part should, perhaps, be added to alshedivat/al-folio in general for all those who want a monolingual website in one of those languages (separately from this commit which is only relevant for multilingual websites).
Aside from that, I would think that the rest can be kept as is (at least in its basic form). Or at least I wouldn't immediately see the advantage of putting the localisation variable elsewhere. Perhaps adding an if-clause that reverts to the first_name
and last_name
in the main language if the variable isn't set for a non-main language? (which seems to already be happening automatically, albeit also producing a non-critical error message which would then be eliminated)
What do you think?
Caveat: The first_name, middle_name, and last_name variables in _config.yml are still required for checking whether or not a value for each category exists (checking with the localized variants doesn't work for me for some reason).
This means that you would have to have a first/middle/last name in each localized language if (and only if) you have one set in __config.yml (otherwise a superfluous non-breaking character is added in the header).
Otherwise, the implementation works fine for me (displayed text and metadata).
I believe you can fix this by looking for the key in the language file. This can be done like this: {% if site.translations[site.lang].main.first_name %}
. Add these changes and I will be happy to accept this PR.
Regarding the order, thinking about it now, maybe it is a good idea to create a new file to handle the order or any other language specific detail that a user might want to handle. This can be useful since the name appears in some places, like about
and footer
. But this can be done in another PR. Now I don't think it is a good idea to add all language ISO codes, since both this repo and al-folio are just templates for people to base their site on, not a one fits all base site.
Your recommendation worked perfectly, thanks! I also fixed a bug that occurred when the main language missed a name variable. It should work perfectly without the entries in _config.yml
now (I tested all combinations, checked the display of header, footer, about-page, and metadata).
Right, I incorporated your feedback. Be aware that this introduces a minor issue: If a person has no first name, there's going to be an empty space character in front of the middle/last name in the metadata (the only way to avoid that, as far as I can tell with my meagre liquid skills, is to do the split+join I originally did or by adding a whole lot of if-conditions).
I am also not a prolific Jekyll dev, but I know there is a different solution to this.
As I once saw posted here, simply using {%- ... -%}
instead of {% ... %}
reduces the whitespaces created by jekyll.
This is not that simple though, since I tried a dumb replace all in the code once, and it stopped showing things correctly. Also note that it is possible to remove the extra spaces in only one direction, by using {% if ... -%}
{%- endif %}
for example, as can be seen in some parts in the code.
Another suggestion for when the name is used in more than one place in the file, like the footer, I think it is better if you use your previous capture
code to store the "full name" in a variable and then just use it where it is needed in the file.
Added the functionality to change the author's name for each language. Helpful for those who want to add localization for languages that do not use the Latin alphabet (e.g. Chinese or Hebrew) or that have grammatical rules that alter name representation (e.g. Esperanto).