Specify UTF-8 encoding for translation file opening#165
Merged
aaltat merged 1 commit intorobotframework:mainfrom Apr 7, 2026
Merged
Conversation
Add UTF-8 encoding when opening translation files.
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific bug where translation JSON files containing non-ASCII characters were decoded using the system default encoding instead of UTF-8, corrupting translated keyword names and documentation.
Changes:
- Open translation JSON files with an explicit
encoding="utf-8"in_translation()to ensure consistent decoding across platforms.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Open translation JSON files with explicit UTF-8 encoding
Problem
I found this issue when trying to run the unit tests for seleniumlibrary on my Windows machine.
Translation files containing non-ASCII characters (e.g. Finnish
ä,ö) are read incorrectly on Windows. The_translation()function inutils/translations.pyopens the file without specifying an encoding, so Python falls back to the system locale encoding (cp1252on Windows). This silently corrupts keyword names and documentation containing multi-byte UTF-8 characters.For example, a translated keyword name
hallinnoi_hälytysis stored ashallinnoi_hälytysinkeywords_spec, making it impossible to look up by its correct name.This does not affect CI pipelines running on Linux, where the default encoding is already UTF-8, which explains why the bug only reproduces locally on Windows.
Fix
Pass
encoding="utf-8"explicitly when opening the translation file inutils/translations.py: