Skip to content

Commit 4716124

Browse files
committed
feature: Linux AppImages support portable data dir (#2062)
Signed-off-by: leo <longshuang@msn.cn>
1 parent d628871 commit 4716124

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,6 @@
6464
> [!WARNING]
6565
> **Linux** only tested on **Debian 12** on both **X11** & **Wayland**.
6666
67-
## Translation Status
68-
69-
You can find the current translation status in [TRANSLATION.md](https://github.com/sourcegit-scm/sourcegit/blob/develop/TRANSLATION.md)
70-
71-
### Translate Utility Script
72-
73-
A script that assists with translations by reading the target language, comparing it with the base language, and going through missing keys one by one, so the translator can provide the translations interactively without needing to check each key manually.
74-
75-
#### Usage
76-
77-
Check for a given language (e.g., `pt_BR`) and optionally check for missing translations:
78-
79-
```bash
80-
python translate_helper.py pt_BR [--check]
81-
```
82-
83-
- `pt_BR` is the target language code (change as needed), it should correspond to a file named `pt_BR.axaml` in the `src/Resources/Locales/` directory, so you can replace it with any other language code you want to translate, e.g., `de_DE`, `es_ES`, etc.
84-
- `--check` is an optional flag used to only check for missing keys without prompting for translations, useful for getting a list of missing translations.
85-
86-
The script will read the base language file (`en_US.axaml`) and the target language file (e.g., `pt_BR.axaml`), identify missing keys, and prompt you to provide translations for those keys. If the `--check` flag is used, it will only list the missing keys without prompting for translations.
87-
8867
## How to Use
8968

9069
**To use this tool, you need to install Git(>=2.25.1) first.**
@@ -101,7 +80,7 @@ This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationD
10180

10281
> [!TIP]
10382
> * You can open this data storage directory from the main menu `Open Data Storage Directory`.
104-
> * You can create a `data` folder next to the `SourceGit` executable to force this app to store data (user settings, downloaded avatars and crash logs) into it (Portable-Mode). Only works on Windows.
83+
> * You can create a `data` folder next to the `SourceGit` executable to force this app to store data (user settings, downloaded avatars and crash logs) into it (Portable-Mode). Only works with Windows packages and Linux AppImages.
10584
10685
For **Windows** users:
10786

@@ -261,6 +240,27 @@ Thanks to all the people who contribute.
261240

262241
[![Contributors](https://contrib.rocks/image?repo=sourcegit-scm/sourcegit&columns=20)](https://github.com/sourcegit-scm/sourcegit/graphs/contributors)
263242

243+
## Translation Status
244+
245+
You can find the current translation status in [TRANSLATION.md](https://github.com/sourcegit-scm/sourcegit/blob/develop/TRANSLATION.md)
246+
247+
### Translate Utility Script
248+
249+
A script that assists with translations by reading the target language, comparing it with the base language, and going through missing keys one by one, so the translator can provide the translations interactively without needing to check each key manually.
250+
251+
#### Usage
252+
253+
Check for a given language (e.g., `pt_BR`) and optionally check for missing translations:
254+
255+
```bash
256+
python translate_helper.py pt_BR [--check]
257+
```
258+
259+
- `pt_BR` is the target language code (change as needed), it should correspond to a file named `pt_BR.axaml` in the `src/Resources/Locales/` directory, so you can replace it with any other language code you want to translate, e.g., `de_DE`, `es_ES`, etc.
260+
- `--check` is an optional flag used to only check for missing keys without prompting for translations, useful for getting a list of missing translations.
261+
262+
The script will read the base language file (`en_US.axaml`) and the target language file (e.g., `pt_BR.axaml`), identify missing keys, and prompt you to provide translations for those keys. If the `--check` flag is used, it will only list the missing keys without prompting for translations.
263+
264264
## Third-Party Components
265265

266266
For detailed license information, see [THIRD-PARTY-LICENSES.md](THIRD-PARTY-LICENSES.md).

src/Native/OS.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ public static void SetupDataDir()
149149
return;
150150
}
151151
}
152+
else if (OperatingSystem.IsLinux())
153+
{
154+
var appImage = Environment.GetEnvironmentVariable("APPIMAGE");
155+
if (!string.IsNullOrEmpty(appImage) && File.Exists(appImage))
156+
{
157+
var portableDir = Path.Combine(Path.GetDirectoryName(appImage)!, "data");
158+
if (Directory.Exists(portableDir))
159+
{
160+
DataDir = portableDir;
161+
return;
162+
}
163+
}
164+
}
152165

153166
var osAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
154167
if (string.IsNullOrEmpty(osAppDataDir))

0 commit comments

Comments
 (0)