L10n howto for Windows based contributors
I am thinking of contributing Italian names for Italian holidays and am following this thread closely. I too am on Windows but don't know the technology/library used here, and am a bit worried as I don't really want to install WSL2. Also worrisome is the lack of support for UTF-8 (based on the error reported above) as it's required for Italian.
As the author of #827 and the make file that doesn't seem to work on Windows, do you have any input on where I should look to be able to contribute a Windows-native solution?
Originally posted by @mborsetti in https://github.com/dr-prodigy/python-holidays/issues/946#issuecomment-1432731177
Here's one of the placeholder methods until we get this working natively on Windows (not ideal, but it works for now).
- Enable "Windows Subsystem for Linux" (WSL2)
wsl --install, select your repo of choice (I pickedUbuntu 22.04 LTSfor this case)- After setting everything up,
wsl ~to enter WSL
- Installing additional packages:
sudo apt update && sudo apt upgrade -yto update Linux distro.sudo apt install gettext -yneeded for localisation.
cdto the installed location:cd /mnt/[drive no]/[whatever folders]/python-holidays- Check
echo $PYTHONPATH; if this is not set yet, runexport PYTHONPATH=/mnt/[drive no]/[whatever folders]/python-holidays - Installing additional python requirements:
pip install --requirement requirements/dev.txt - Creating the following files and folders (either in Windows Explorer's GUI or
mkdirin the command line):holidays/locale/potholidays/locale/[new_language_code]/LC_MESSAGES/[new_language_code].po← (if new translation files, both for the new languages and in the English folder)
- You should now be able to run
make l10n
Edit: For countries with non-ASCII holiday names, instead of merely blank files you'll need to add header to the file itself to get the code working, here's an example:
# CountryName holidays English translation.
# Authors: AuthorName <[email protected]>, (c) 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: Python Holidays 0.20\n"
"POT-Creation-Date:\n"
"PO-Revision-Date: \n"
"Last-Translator: AuthorName <[email protected]>\n"
"Language-Team: Python Holidays localization team\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
Respectfully, this is not a recipe on how to enable contributions from the Windows community (~50+% of computers). It's one for installing a brand new operating system chewing up over ~5GB of space, which is a huge ask!!
I think we can do better; most open source projects I am aware of are cross-platform compatible.
As the author of #827 and the
makefile that doesn't seem to work on Windows, do you have any input on where I should look to be able to contribute a Windows-native solution?
Hi, I encountered the same error while setting up the project, so I made general modifications to the Makefile. This change will not cause errors on Linux machines during execution. Should I create a pull request?
@Prateekshit73 I'm not sure if that solves the original Windows-related problem but yeah go ahead and create a PR!
@Prateekshit73 I'm not sure if that solves the original Windows-related problem but yeah go ahead and create a PR!
Is this the original Windows-related problem you are referring to:-
make[1]: *** [Makefile:60: pre-commit] Error 1
make[1]: Leaving directory 'vacanza_holidays'
make: *** [Makefile:32: check] Error 2
I think the cause of error is line endings:
- Linux uses LF (Line Feed, \n) as the line ending.
- Windows uses CRLF (Carriage Return + Line Feed, \r\n).
@Prateekshit73 I'm not sure if that solves the original Windows-related problem but yeah go ahead and create a PR!
Is this the original Windows-related problem you are referring to:-
make[1]: *** [Makefile:60: pre-commit] Error 1 make[1]: Leaving directory 'vacanza_holidays' make: *** [Makefile:32: check] Error 2
I'm not sure how it looks like specifically. The problem is that make command is not a part of Windows out of the box and you need to install WSL for that. From my perspective it's not really a blocker for contributing to holidays as a Makefile is just a way to group multiple commands into a single command in our case.
We still want to make the contribution process easier for Windows users if possible.
Thank you for your feedback! To verify the issue, I spun up a Windows VM and ran the command. As I mentioned earlier, it seems that the problem is related to the line endings. I’ll look into this further to ensure compatibility for Windows users. If you have any suggestions on how to address this, I’d appreciate your input!
Still, the issue persists when we try to push with git push without the --no-verify flag, as it automatically falls back to the Makefile supported by Linux.
run `make check`.........................................................Failed
- hook id: tests
- exit code: 2
make l10n
make[1]: Entering directory 'vacanza_holidays'
scripts/l10n/generate_po_files.py >/dev/null 2>&1
make[1]: *** [Makefile:36: l10n] Error 49
make[1]: Leaving directory 'vacanza_holidays'
make: *** [Makefile:15: check] Error 2
That's strange. Make.cmd in the current folder should take priority over Make located somewhere in the PATH.
Hi @KJhellico,
The problem still persists as I mentioned earlier. Even with Make.cmd in the current folder, it doesn’t seem to take priority over the Linux-style Make in the PATH when running commands like git push without the --no-verify flag. It continues to fall back to the Makefile designed for Linux, resulting in errors like:
run `make check`.........................................................Failed
- hook id: tests
- exit code: 2
make l10n
make[1]: Entering directory 'vacanza_holidays'
scripts/l10n/generate_po_files.py >/dev/null 2>&1
make[1]: *** [Makefile:36: l10n] Error 49
make[1]: Leaving directory 'vacanza_holidays'
make: *** [Makefile:15: check] Error 2
I’ve tested this on Windows. Do you have any thoughts on how to ensure Make.cmd is prioritized or other ways to resolve this for Windows users?
Yes, git runs its hooks through bash (Cygwin), so it doesn't consider make.cmd.
Try specifying python for .py scripts in Makefile explicitly (i.e.
python scripts/l10n/generate_po_files.py ...