-
Notifications
You must be signed in to change notification settings - Fork 6
Testing a Language File
Starting with Get My IP version 0.9.3, language contributors can test a language file prior to submitting a PR.
Testing allows you to check:
- That the language string is spelled and formatted correctly
- That the language file is syntactically correct
- That the language string is right for the context
- That it fits in the space provided
- The application always loads the en-US file first. This file contains all the language strings available to the application. It is the base from which other language files are derived.
- If a language other than en-US is selected in Language Settings, it will be loaded next.
- These first files are compiled into the application and are not accessible for changes.
- If the 'Enable language testing' option in Language settings is enabled, the test language file is loaded last.
- This file is located in the application folder. It is an XML file that can be edited.
When the application needs a language string, it searches these files from last to first. This enables the application to always find the language string, even if it needs to fall back to the default in the en-US file. This behavior allows us to use the test language file to check one or a few strings.
- Start Get My IP and navigate to Language Setting.
- Click the 'Open App Folder' button on the bottom row. This will open the folder in File Explorer.

- Open the file named Strings.test.xaml with your editor. I suggest using an editor that will provide syntax highlighting for XML files. Xaml file are really just XML files.
- The file will look much like this:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<!--
=============================================================================================================================
Use this file for language testing. Any number (or all) of the language strings for a single language can be in this file.
The application will need to be restarted after each change to this.
=============================================================================================================================
-->
<sys:String x:Key="NavTitle_Settings">Settings - Language Test</sys:String>
</ResourceDictionary>- Replace the provided string with the strings that are to be tested. Any number of strings can be added, from one line to the entire file.
- Keep in mind that the
ResourceDictionarytags at the beginning and end of the file must remain as they are. Refer to the contribution topic if needed. - After the strings have been added, save the file. The file name must be Strings.test.xaml. The application will not find the file if it is renamed or in another folder. Additionally, ensure that the line endings are CRLF.
- Once the file is saved return to Get My IP and check the Enable language testing checkbox. The application will restart.

- You should now see your language strings.
- Should you need to make changes, you will need to restart the application to see the changes.
The application log will contain two messages that are relevant to language testing. The first message indicates that language testing has been enabled. The second will show how many strings were loaded from the test language file.
2023/10/31 16:42:39.33 INFO Language testing enabled
2023/10/31 16:42:39.33 DEBUG 14 strings loaded from D:\blah\blah\Strings.test.xaml
If there are errors, a message box will be shown. The language files are loaded before logging is available, so the message box will be the only source of an error message. The message box will contain the error message. In the following example, a line in the file was repeated, causing a duplicate key.

14. <sys:String x:Key="NavTitle_Settings">Settings - Language Test</sys:String>
15. <sys:String x:Key="NavTitle_Settings">Settings - Language Test</sys:String>In the blue box, the message indicates the line number (15 in this case) and position of the error. In the red box, the message indicates that the key has already been added and the name of the key is 'NavTitle_Settings'.
The application was written in English. The same word or phrase may be longer in other languages. I've tried to allow room for this, but I've probably overlooked something. Just open an issue and we'll work on it together. 😃
Pretty simple, right? 😂