mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 08:47:40 +01:00
chore: update l10n scripts for country code (#970)
This commit is contained in:
parent
49b894fed9
commit
d7ac02101b
@ -152,8 +152,11 @@ In this case, you should:
|
||||
|
||||
### 3.4 Add a new localization
|
||||
|
||||
The preferred way for localizations (l10ns) is to submit a pull request (PR) as detailed in
|
||||
the [next section](#35-submit-a-pull-request).
|
||||
> [!NOTE]
|
||||
> This section explains how translation are managed in the app (creating a new implementation of the
|
||||
> Strings interface, modify the bottom sheet to allow selecting it etc.) and it is useful to
|
||||
> understand the global mechanism. However, translators are encouraged to review the messages on
|
||||
> Weblate and leave all the heavy-lifting work to project maintainers.
|
||||
|
||||
The project uses
|
||||
the [Lyricist](https://github.com/adrielcafe/lyricist) library for internationalization, which
|
||||
@ -177,10 +180,10 @@ anonymous implementation of `Strings` stored in a variable called `XxYyStrings`
|
||||
```kotlin
|
||||
|
||||
internal val XxYyStrings =
|
||||
object : Strings {
|
||||
override val actionBackToTop = "..."
|
||||
// ... continue overriding all the remaining properties
|
||||
}
|
||||
object : Strings {
|
||||
override val actionBackToTop = "..."
|
||||
// ... continue overriding all the remaining properties
|
||||
}
|
||||
```
|
||||
|
||||
It is recommended to copy the contents of the existing `EnStrings.kt` (i.e. the base localization)
|
||||
@ -193,15 +196,15 @@ Afterwards, edit the `Strings.kt` file in the same directory with the following
|
||||
|
||||
```kotlin
|
||||
object Locales {
|
||||
// ...
|
||||
const val XX_YY = "xx_YY"
|
||||
// ...
|
||||
const val XX_YY = "xx_YY"
|
||||
}
|
||||
|
||||
internal val localizableStrings: Map<LanguageTag, Strings> =
|
||||
mapOf(
|
||||
// ...
|
||||
Locales.XX_YY to XxYyStrings,
|
||||
)
|
||||
mapOf(
|
||||
// ...
|
||||
Locales.XX_YY to XxYyStrings,
|
||||
)
|
||||
```
|
||||
|
||||
Finally, if you want you can change the rest of the code (e.g. the language dialog, etc) please do
|
||||
|
66
README.md
66
README.md
@ -86,7 +86,8 @@ for some technical notes.
|
||||
- multi-community (community aggregation);
|
||||
- view the moderation log;
|
||||
- community moderation tool (examine and resolve reports, ban users, feature posts, block
|
||||
further comments from posts, mark comments as distinguished, remove posts/comments, examine all posts/comments created
|
||||
further comments from posts, mark comments as distinguished, remove posts/comments, examine all
|
||||
posts/comments created
|
||||
in your communities);
|
||||
- save posts and comments you are creating as drafts to edit them later;
|
||||
|
||||
@ -94,31 +95,42 @@ Most clients for Lemmy currently offer the first points (with various degrees of
|
||||
there is nothing special about Raccoon, whereas the last ones are less common and are directed to
|
||||
more demanding users.
|
||||
|
||||
Concerning customization, the ability to change some aspects like font face or size and app colors, vote format, bar
|
||||
transparency and so on was of paramount importance from the very beginning. Similarly, users should be able to use the
|
||||
Concerning customization, the ability to change some aspects like font face or size and app colors,
|
||||
vote format, bar
|
||||
transparency and so on was of paramount importance from the very beginning. Similarly, users should
|
||||
be able to use the
|
||||
app in their native language and change the UI language independently of the system language.
|
||||
|
||||
This app is also intended for moderators who want to use their mobile device, offering moderation tools (feature post,
|
||||
lock post, distinguish comment, remove post/comment, ban users) and the ability to revert any of these actions.
|
||||
This app is also intended for moderators who want to use their mobile device, offering moderation
|
||||
tools (feature post,
|
||||
lock post, distinguish comment, remove post/comment, ban users) and the ability to revert any of
|
||||
these actions.
|
||||
|
||||
The project is under active development, so expect new features to be added over time. Have a look on the issues labeled
|
||||
The project is under active development, so expect new features to be added over time. Have a look
|
||||
on the issues labeled
|
||||
with "feature" in the issue tracker to get an idea of what's going to come next.
|
||||
|
||||
If you have ideas, feedback, suggestions or comments remember to speak up and use your voice. You can add reports or
|
||||
If you have ideas, feedback, suggestions or comments remember to speak up and use your voice. You
|
||||
can add reports or
|
||||
request features and they will be considered.
|
||||
|
||||
## Why was the project started?
|
||||
|
||||
Because raccoons are so adorable, aren't they? 🦝🦝🦝
|
||||
|
||||
Joking apart, one of the main goals was to experiment with KMP and learn how to properly deal with the challenges of a
|
||||
multiplatform environment, and a medium-sized project like this was an ideal testing ground for that technology.
|
||||
Joking apart, one of the main goals was to experiment with KMP and learn how to properly deal with
|
||||
the challenges of a
|
||||
multiplatform environment, and a medium-sized project like this was an ideal testing ground for that
|
||||
technology.
|
||||
|
||||
Secondly, I felt that the Android ecosystem of Lemmy apps was a little "poor" with few native apps (fewer open source),
|
||||
while the "market" is dominated by iOS and cross-platform clients. I️ ❤️ Kotlin, I ❤️ Free and Open Source Software and
|
||||
Secondly, I felt that the Android ecosystem of Lemmy apps was a little "poor" with few native apps (
|
||||
fewer open source),
|
||||
while the "market" is dominated by iOS and cross-platform clients. I️ ❤️ Kotlin, I ❤️ Free and Open
|
||||
Source Software and
|
||||
I ❤️ native app development, so there was a niche that could be filled.
|
||||
|
||||
Developing a new client was an opportunity to add all the good features that were "scattered" across different apps,
|
||||
Developing a new client was an opportunity to add all the good features that were "scattered" across
|
||||
different apps,
|
||||
e.g. the feature richness of [Liftoff](https://github.com/liftoff-app/liftoff), the
|
||||
multi-community feature of
|
||||
[Summit](https://github.com/idunnololz/summit-for-lemmy) and the polished UI of the really great
|
||||
@ -126,10 +138,13 @@ multi-community feature of
|
||||
enough to make users feel "at home" and choose what they want, while at the same time having a not
|
||||
too cluttered interface (except for the Settings screen - I know!)
|
||||
|
||||
In the third place, this app has been a means to dig deeper inside Lemmy's internals and become more humble and patient
|
||||
towards other apps because there are technical difficulties in having to deal with a platform like Lemmy.
|
||||
In the third place, this app has been a means to dig deeper inside Lemmy's internals and become more
|
||||
humble and patient
|
||||
towards other apps because there are technical difficulties in having to deal with a platform like
|
||||
Lemmy.
|
||||
|
||||
This involves a high level of discretion and personal taste, I know, but this project _is_ all about experimenting and
|
||||
This involves a high level of discretion and personal taste, I know, but this project _is_ all about
|
||||
experimenting and
|
||||
learning.
|
||||
|
||||
## Technical notes:
|
||||
@ -138,12 +153,16 @@ The project uses the following technologies:
|
||||
|
||||
- [Koin](https://github.com/InsertKoinIO/koin) for dependency injection
|
||||
- [Voyager](https://github.com/adrielcafe/voyager) for screen navigation
|
||||
- [Ktor](https://github.com/ktorio/ktor) and [Ktorfit](https://github.com/Foso/Ktorfit) for networking
|
||||
- [Ktor](https://github.com/ktorio/ktor) and [Ktorfit](https://github.com/Foso/Ktorfit) for
|
||||
networking
|
||||
- [Lyricist](https://github.com/adrielcafe/lyricist) for l10n
|
||||
- [Multiplatform settings](https://github.com/russhwolf/multiplatform-settings) for encrypted preferences
|
||||
- [SQLDelight](https://github.com/cashapp/sqldelight) and [SQLCipher](https://github.com/sqlcipher/sqlcipher) for local
|
||||
- [Multiplatform settings](https://github.com/russhwolf/multiplatform-settings) for encrypted
|
||||
preferences
|
||||
- [SQLDelight](https://github.com/cashapp/sqldelight)
|
||||
and [SQLCipher](https://github.com/sqlcipher/sqlcipher) for local
|
||||
persistence
|
||||
- [Multiplatform Markdown Renderer](https://github.com/mikepenz/multiplatform-markdown-renderer) for Markdown
|
||||
- [Multiplatform Markdown Renderer](https://github.com/mikepenz/multiplatform-markdown-renderer) for
|
||||
Markdown
|
||||
rendering
|
||||
|
||||
More info about the technologies used in the project can be found in
|
||||
@ -157,11 +176,12 @@ the [CONTRIBUTING.md](https://github.com/diegoberaldin/RaccoonForLemmy/blob/mast
|
||||
- create a post on the project's [community](https://lemmy.world/c/raccoonforlemmy) on
|
||||
Lemmy.world for broader questions, opinions, personal feedback, suggestions, insults or whatever
|
||||
you feel like writing
|
||||
- if you are a translator and want to help out with l10n or submit some corrections but you don't
|
||||
feel confident with repository forks, pull requests, managing resource files, etc. feel free to
|
||||
drop an email or contact me in any way.
|
||||
- if you are a translator and want to help out with l10n or submit some corrections, check out the
|
||||
project [on Weblate](https://hosted.weblate.org/projects/raccoonforlemmy/), so you can review the
|
||||
existing messages or add missing ones.
|
||||
|
||||
Please remember: every contribution is welcome and everyone's opinion matters here. This is a community project, open
|
||||
Please remember: every contribution is welcome and everyone's opinion matters here. This is a
|
||||
community project, open
|
||||
source, ad-free and free of charge, and it belongs to us all so don't be afraid to get involved.
|
||||
|
||||
And don't forget every 🦝's motto: «Live Fast, Eat Trash» (abbreviated L.F.E.T.).
|
||||
|
@ -47,11 +47,14 @@ def convert(input_path, output_path):
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: {0} lang".format(sys.argv[0]))
|
||||
print("Usage: {0} lang_code country_code".format(sys.argv[0]))
|
||||
return
|
||||
lang = sys.argv[1]
|
||||
source_file = "../core/l10n/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/l10n/messages/{0}Strings.kt".format(lang.capitalize())
|
||||
dest_file = "../l10n/strings_{0}.xml".format(lang)
|
||||
lang_code = sys.argv[1]
|
||||
country_code = ""
|
||||
if len(sys.argv) > 2:
|
||||
country_code = sys.argv[2]
|
||||
source_file = "../core/l10n/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/l10n/messages/{0}{1}Strings.kt".format(lang_code.capitalize(), country_code.capitalize())
|
||||
dest_file = "../l10n/strings_{0}{1}.xml".format(lang_code, country_code)
|
||||
if not os.path.isdir("../l10n"):
|
||||
os.mkdir("../l10n")
|
||||
convert(source_file, dest_file)
|
||||
|
@ -15,28 +15,31 @@ def read_l10n_from_file(input_path):
|
||||
res.append({"key": k, "value": v})
|
||||
return res
|
||||
|
||||
def write_l10n_to_file(lang, messages, output_path):
|
||||
def write_l10n_to_file(lang_code, country_code, messages, output_path):
|
||||
with open(output_path, "w") as file_handle:
|
||||
file_handle.write("package com.github.diegoberaldin.raccoonforlemmy.core.l10n.messages\n")
|
||||
file_handle.write("\n")
|
||||
file_handle.write("internal val {0}Strings =\n".format(lang.capitalize()))
|
||||
file_handle.write("internal val {0}{1}Strings =\n".format(lang_code.capitalize(), country_code.capitalize()))
|
||||
file_handle.write(" object : Strings {\n")
|
||||
for pair in messages:
|
||||
file_handle.write(" override val {0} = \"{1}\"\n".format(pair["key"], pair["value"]))
|
||||
file_handle.write(" }\n")
|
||||
|
||||
def convert(lang, input_path, output_path):
|
||||
def convert(lang_code, country_code, input_path, output_path):
|
||||
messages = read_l10n_from_file(input_path)
|
||||
write_l10n_to_file(lang, messages, output_path)
|
||||
write_l10n_to_file(lang_code, country_code, messages, output_path)
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: {0} lang".format(sys.argv[0]))
|
||||
print("Usage: {0} lang_code country_code".format(sys.argv[0]))
|
||||
return
|
||||
lang = sys.argv[1]
|
||||
source_file = "../l10n/strings_{0}.xml".format(lang)
|
||||
dest_file = "../core/l10n/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/l10n/messages/{0}Strings.kt".format(lang.capitalize())
|
||||
convert(lang, source_file, dest_file)
|
||||
lang_code = sys.argv[1]
|
||||
country_code = ""
|
||||
if len(sys.argv) > 2:
|
||||
country_code = sys.argv[2]
|
||||
source_file = "../l10n/strings_{0}{1}.xml".format(lang_code, country_code)
|
||||
dest_file = "../core/l10n/src/commonMain/kotlin/com/github/diegoberaldin/raccoonforlemmy/core/l10n/messages/{0}{1}Strings.kt".format(lang_code.capitalize(), country_code.capitalize())
|
||||
convert(lang_code, country_code, source_file, dest_file)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user