Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Internationalisation of Name #4

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

DavidKrassnig
Copy link

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).

@DavidKrassnig
Copy link
Author

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).

@DavidKrassnig DavidKrassnig force-pushed the multi-language-al-folio-main-name-i18n branch from b2c0602 to 892ad02 Compare July 18, 2023 13:46
@george-gca
Copy link
Owner

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?

@DavidKrassnig
Copy link
Author

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?

@george-gca
Copy link
Owner

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.

@DavidKrassnig
Copy link
Author

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).

@george-gca george-gca self-requested a review July 21, 2023 15:11
_includes/footer.html Outdated Show resolved Hide resolved
_includes/footer.html Outdated Show resolved Hide resolved
_includes/footer.html Outdated Show resolved Hide resolved
_includes/header.html Outdated Show resolved Hide resolved
@DavidKrassnig DavidKrassnig force-pushed the multi-language-al-folio-main-name-i18n branch from 143b887 to ba187d6 Compare July 21, 2023 16:17
@DavidKrassnig
Copy link
Author

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).

@george-gca
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants