8.2 KiB
Contributing To LOOT
A general guide to contributing to LOOT, may be found on LOOT's website. Information more specific to this repository is found here.
Repository Branching Structure
The repository branching structure is pretty simple:
- The
masterbranch holds released code. - The
devbranch is a next-release branch. It holds code that's working towards the next big release but which isn't there yet. Code ondevis generally pretty stable as CI must pass before anything can be merged into it, but may not be release-ready. - Other branches are generally themed on specific features or groups of changes, and come and go as they are merged into one of the two above, or discarded.
Getting Involved
The best way to get started is to comment on something in GitHub's commit log or on the issue tracker (new tracker entries are always welcome).
Surprise pull requests aren't recommended because everything you touched may have been rewritten, making your changes a pain to integrate, or obsolete. There are only generally a few contributors at any one time though, so there's not much chance of painful conflicts requiring resolution, provided you're working off the correct branch.
When you do make a pull request, please do so from a branch which doesn't have the same name as they branch you're requesting your changes to be merged into. It's a lot easier to keep track of what pull request branches do when they're named something like you:specific-cool-feature rather than you:master.
Translating LOOT
General Information
LOOT supports translation into other languages, with the following limitations:
- Debug log messages and error messages generated by the libraries LOOT uses cannot be translated.
- Masterlist messages can be translated, but translations must be submitted to the masterlist maintainers for addition. Translating masterlist messages won't be covered here.
- The languages LOOT supports is hardcoded, so LOOT must be updated to include new translations.
To translate everything but masterlist messages, first fork this repository. All file paths given below are relative to its base folder.
Translating the Installer
First check that an Inno Setup translation exists for your language. Unofficial translations are acceptable, but require a bit of extra handling. If there isn't an official or unofficial translation for Inno Setup, you're better off making a translation and getting it listed on the linked page before continuing.
- Open the installer script at
scripts/installer.issin a text editor of your choice. - If your language only has an unofficial translation, add a
#define <Language>Existsblock for it near the top of the script, like it has been done for Korean and Simplified Chinese. - Add your language to the
[Languages]section. TheNamemust be the POSIX locale code for your language. TheMessagesFilefilename is the filename of the Inno Setup translation that you checked exists. If your language only has an unofficial translation, wrap its line in#ifdefand#endiflines, again like it has been done for Korean and Simplified Chinese. - Translate the string(s) in the
[CustomMessages]into your language, following the example of the existing translations. Again, if your language only has an unofficial translation, wrap its line(s) in#ifdefand#endiflines. - Save your changes.
Translating the LOOT application
- Download and install the latest version of Poedit.
- If you are starting a new translation, select
File->New catalogue from POT file...and choose the template file atresources/l10n/template.pot. In theCatalog propertiesdialog, just clickOKwithout changing anything. - If you are updating a previous translation, open in Poedit the
loot.potranslation file in the relevant subdirectory ofresources/l10n, then selectCatalogue->Update from POT file...and choose the template file you downloaded. ClickOKin theUpdate summarydialog. - Edit the translation file to add or update translations of the programs' text. Strings that were added since the last translation are displayed in bold and dark blue, and strings you have edited the translations of are marked with a star to the left of their source text in the main list.
- Save the translation file with the filename
loot.poinresources/l10n/<locale>/LC_MESSAGES/, where<locale>is your language's POSIX locale code.
Some languages may use different words or phrases for different contexts where only one word or phrase may be used for all contexts in English. While no contextual information is supplied to translators by default, it can be added on request. To request the addition of contextual information to a text string, create an issue for your request in LOOT's source code issue tracker, quoting the string for which you are requesting contextual information.
Some strings to be translated may contain special characters. Different types of special character that may be encountered are:
-
Backslashes (
\). These are used to escape backslashes and double-quotation marks (") in the C++ translation strings. Don't add new backslashes into translations, and make sure all backslashes in the original string are retained in the translation. -
Formatting placeholders are used so that LOOT can substitute text or numbers that are generated at runtime into pre-made strings. They appear in a few different formats:
- A number surrounded by percentage signs, eg.
%1%. - A named placeholder, eg.
%(icon)s(the name in parentheses must not be changed). - A simple placeholder
%s.
If formatting placeholders are used in the untranslated string, they must all be present in the translated string, or LOOT will encounter an error when it tries to display the translated string. Placeholders can be moved around so that the sentence makes grammatical sense in the target language.
- A number surrounded by percentage signs, eg.
-
A small number of strings also include HTML
<span>elements that wrap translatable text. While the text inside the elements should be translated, the element tags and their attributes should not be.
Adding A New Translation
If you're adding a new translation, LOOT's source code must be updated to recognise it. You can do this yourself and include the changes in your translation's pull request if you wish. The files and functions which must be updated are given below.
- In language_code.h, append a value for the language to the
LanguageCodeenum. - In language.cpp, define the value for the constant you added, and update
Language::Language(LanguageCode code)andLanguage::codes({...})to include lines for your language. - In archive.js, add the language folder to the list returned by
getLanguageFolders(). - In installer.iss, add an entry for your language's translation file to the
[Files]section. - In localised_content.rst, add a row for your language to the Language Codes table.
Code Style
LOOT's JavaScript uses a slightly tweaked version of the Airbnb style, and can be automatically linted by ESLint, so isn't covered here.
C++ Code Style
The Google C++ Style Guide is used as the base, with deviations as listed below.
C++ Features
- Static variables may contain non-POD types.
- Reference arguments don't need to be
const(ie. they can be used for output variables). - Exceptions can be used.
- Unsigned integer types can be used.
- There's no restriction on which Boost libraries can be used.
- Specialising
std::hashis allowed.
Naming
- Constant, enumerator and variable names should use
camelCaseorunderscore_separators, but they should be consistent within the same scope. - Function names should use
PascalCaseorcamelCase, but they should be consistent within the same scope.
Formatting
- Line length doesn't matter.
public,protectedandprivatekeywords should not be indented within a class declaration.