Import localizations from Excel (.xlsx)
Spreadsheets are a great way to organize data, in an accessible and portable way. This is why it is (or was) a first choice for many of us when it came to sharing localizations with team members or translators.
Respresso can help you to transition from the error-prone, mostly manually executed copy & paste to the source code method.
Expected localization spreadsheet layout
To import localizations from xlsx file, Respresso expects a few things:
- You have a row for each localization.
- Translations of the same language are in a separate column.
- Each localization has a unique key that is present on the same sheet (tab) as the translation.
- You can have a header as the first row that can be omitted.
- Empty keys or translations are not a thing, so they can be ignored. (This allows you to have partial translations of a language and also separating headers with unified cells that will be ignored this way.)
Let's see an example of a proper spreadsheet layout:
Probably, this is the way you have organized your localizations anyway, but make sure your file looks like this example before importing it.
Import your localizations
If you have a properly organized localization spreadsheet, you can import it by following the steps in the import section.
Don't forget to switch to the language you want to import, before importing a spreadsheet. (You might need to add the language.)
Import options
When you uploaded the file, you will see a few XLSX specific import options:
Let's dive in to your xlsx options (others are described in the import section).
Sheet index
The sheetIndex
option tells Respresso which sheet contains the translations of the language you are going to import.
It is a 0 based index, so to import from the first sheet, you have to use 0 as the index.
Defaults to 0, referencing the first sheet.
Keep in mind, that the keys must be present on the same sheet and row as the translations.
Has header
The hasHeader
option tells Respresso if the first row should be treated like a header.
The header will be ignored during the import.
Defaults to true, so the first row will be omitted.
Key column index
The keyColumnIndex
tells Respresso which column should be used pick the keys from.
It is a 0 based index, so to use the first column, you have to use 0 as the index.
Defaults to 0, referencing the first column.
Keep in mind, that that rows, where the key column is empty are going to be ignored.
Translation column index
The translationColumnIndex
tells Respresso which column should be used to pick the current language's translations from.
It is a 0 based index, so to use the second column, you have to use 1 as the index.
Defaults to 1, referencing the second column.
Keep in mind, that that rows, where the referenced translation column is empty are going to be ignored.
Example
If you take a look to the example spreadsheet layout, the default options will import the English language, and omit the header row.
To import the other translation (Hungarian), you only need to change the translation column index to 2.
Use the default translation as the key
Sometimes, developers don't specify keys for localizations, instead they use the default language's value as the key. (Unfortunately, this is widespread in iOS development, although it is a very bad practice. Seriously, you should always use meaningful keys.)
There is no restriction on the key and translation index options, so you can reference the same column as the key and the translation. Using this trick, you can import the localizations from a single column.
In the above example, to import the English localizations with the same key as the English translation, you need to use 1 as the keyColumnIndex
and also the translationColumnIndex
.
Once you have imported the English localizations, with the English value as the key, you can import the Hungarian translations with 1 as the keyColumnIndex
and 2 as the translationColumnIndex
Import the keys
Similarly to the previous example you can import only a single column of keys from a spreadsheet. This is useful, when you predefine the keys before they get worded. The key will be imported as the language, but it can be translated in Respresso, or reimported when your spreadsheet gets translated.