mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 02:12:30 +01:00
add possibility to test locales locally
https://github.com/mifi/lossless-cut/issues/1500#issuecomment-1461780597
This commit is contained in:
parent
fe9865e788
commit
0edb7cf31e
@ -169,7 +169,7 @@ Unsupported files can still be converted to a supported format/codec from the `F
|
||||
|
||||
## [Command line interface (CLI)](cli.md)
|
||||
|
||||
## [Developer notes](developer-notes.md)
|
||||
## [Contributing](developer-notes.md)
|
||||
|
||||
## [Known issues, limitations, troubleshooting, FAQ](issues.md)
|
||||
|
||||
|
@ -1,7 +1,41 @@
|
||||
## Development
|
||||
# Contributing
|
||||
|
||||
## Translators
|
||||
|
||||
You are welcome to help translate the app at [Weblate](https://hosted.weblate.org/projects/losslesscut/losslesscut/). Weblate will automatically push translations as a Pull Request in this repo, but this PR is not merged immediately by maintainers.
|
||||
|
||||
Master language is english.
|
||||
|
||||
### Testing translations locally
|
||||
|
||||
To test new weblate translations you made in the app itself, you need to:
|
||||
1. Download the translation for your language from Weblate: **Files -> Download translation**
|
||||
2. Rename the downloaded `.json` file to: `translation.json`
|
||||
3. Create a [folder structure](https://github.com/mifi/lossless-cut/tree/master/public/locales) somewhere on your computer that looks like this:
|
||||
```
|
||||
translations/locales/localeCode
|
||||
```
|
||||
You can find a list of the available [`localeCode`s here](https://github.com/mifi/lossless-cut/tree/master/public/locales). In our example we will use `nb_NO` (Norwegian) with this path:
|
||||
```
|
||||
/Users/mifi/Desktop/translations/locales/nb_NO
|
||||
```
|
||||
|
||||
4. Now move your `translation.json` file into the folder:
|
||||
```
|
||||
/Users/mifi/Desktop/translations/locales/nb_NO/translation.json
|
||||
```
|
||||
|
||||
5. Now run LosslessCut from the [command line](cli.md), with the special command line argument `--locales-path`. Use the path to the **folder containing the locales folder**, e.g.:
|
||||
```bash
|
||||
./LosslessCut --locales-path /Users/mifi/Desktop/translations
|
||||
```
|
||||
|
||||
Now LosslessCut will use your language file.
|
||||
|
||||
## Development setup
|
||||
|
||||
This app is built using Electron.
|
||||
Make sure you have at least Node v14. The app uses ffmpeg from PATH when developing.
|
||||
Make sure you have at least Node v16. The app uses ffmpeg from PATH when developing.
|
||||
|
||||
```bash
|
||||
npm install -g yarn
|
||||
@ -12,6 +46,7 @@ git clone https://github.com/mifi/lossless-cut.git
|
||||
cd lossless-cut
|
||||
yarn
|
||||
```
|
||||
|
||||
Note: `yarn` may take some time to complete.
|
||||
|
||||
### Installing `ffmpeg`
|
||||
|
@ -18,6 +18,8 @@ const { frontendBuildDir } = require('./util');
|
||||
|
||||
const { checkNewVersion } = require('./update-checker');
|
||||
|
||||
const i18nCommon = require('./i18n-common');
|
||||
|
||||
require('./i18n');
|
||||
|
||||
const { app, ipcMain, shell, BrowserWindow, nativeTheme } = electron;
|
||||
@ -156,6 +158,9 @@ function parseCliArgs(rawArgv = process.argv) {
|
||||
|
||||
const argv = parseCliArgs();
|
||||
|
||||
if (argv.localesPath != null) i18nCommon.setCustomLocalesPath(argv.localesPath);
|
||||
|
||||
|
||||
function safeRequestSingleInstanceLock(additionalData) {
|
||||
if (process.mas) return true; // todo remove when fixed https://github.com/electron/electron/issues/35540
|
||||
|
||||
|
@ -6,7 +6,16 @@ const { join } = require('path');
|
||||
|
||||
const { frontendBuildDir } = require('./util');
|
||||
|
||||
const getLangPath = (subPath) => (isDev ? join('public', subPath) : join(app.getAppPath(), frontendBuildDir, subPath));
|
||||
let customLocalesPath;
|
||||
function setCustomLocalesPath(p) {
|
||||
customLocalesPath = p;
|
||||
}
|
||||
|
||||
function getLangPath(subPath) {
|
||||
if (customLocalesPath != null) return join(customLocalesPath, subPath);
|
||||
if (isDev) return join('public', subPath);
|
||||
return join(app.getAppPath(), frontendBuildDir, subPath);
|
||||
}
|
||||
|
||||
// Weblate hardcodes different lang codes than electron
|
||||
// https://www.electronjs.org/docs/api/app#appgetlocale
|
||||
@ -47,4 +56,10 @@ const commonI18nOptions = {
|
||||
const loadPath = (lng, ns) => getLangPath(`locales/${mapLang(lng)}/${ns}.json`);
|
||||
const addPath = (lng, ns) => getLangPath(`locales/${mapLang(lng)}/${ns}.missing.json`);
|
||||
|
||||
module.exports = { fallbackLng, loadPath, addPath, commonI18nOptions };
|
||||
module.exports = {
|
||||
fallbackLng,
|
||||
loadPath,
|
||||
addPath,
|
||||
commonI18nOptions,
|
||||
setCustomLocalesPath,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user