Skip to content

Commit

Permalink
[CI skip] Crowdin setup (squashed)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBusyBiscuit committed May 5, 2021
1 parent c48ccc0 commit 8a1eba8
Show file tree
Hide file tree
Showing 198 changed files with 10,413 additions and 11,583 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You can check out our [Developer Guide](https://github.com/Slimefun/Slimefun4/wi

## :earth_africa: 4. Pull Requests: Translations
Another great way to contribute to Slimefun is by working on translations for the project.
Slimefun's translation is available on [gitlocalize.com](https://gitlocalize.com/repo/3841).
Slimefun's translation is available on [Crowdin](https://crowdin.com/project/slimefun).
Just find a language you are fluent in and translate away. But make sure to submit a "Review Request" when you are done.
One of our Language Moderators will review the changes and submit a Pull Request to the project for you.

Expand Down
3 changes: 3 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
files:
- source: /src/main/resources/languages/en/*.yml
translation: /src/main/resources/languages/%osx_locale%/%original_file_name%
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<!-- Code Coverage Reports -->
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.7</version>

<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
Expand Down Expand Up @@ -122,8 +123,10 @@ public Collection<Language> getLanguages() {
@Override
public boolean hasLanguage(@Nonnull String id) {
Validate.notNull(id, "The language id cannot be null");

// Checks if our jar files contains a messages.yml file for that language
return containsResource(id, LanguageFile.MESSAGES);
String file = LanguageFile.MESSAGES.getFilePath(id);
return !streamConfigFile(file, null).getKeys(false).isEmpty();
}

/**
Expand All @@ -139,13 +142,6 @@ public boolean isLanguageLoaded(@Nonnull String id) {
return languages.containsKey(id);
}

private boolean containsResource(@Nonnull String languageId, @Nonnull LanguageFile file) {
Validate.notNull(languageId, "Language id cannot be null");
Validate.notNull(file, "Language file cannot be null");

return plugin.getClass().getResource(file.getFilePath(languageId)) != null;
}

@Override
public Language getDefaultLanguage() {
return defaultLanguage;
Expand Down Expand Up @@ -253,13 +249,15 @@ public double calculateProgress(@Nonnull Language lang) {
return Math.min(NumberUtils.reparseDouble(100.0 * (matches / (double) defaultKeys.size())), 100.0);
}

@Nullable
@Nonnull
private FileConfiguration streamConfigFile(@Nonnull String file, @Nullable FileConfiguration defaults) {
if (plugin.getClass().getResourceAsStream(file) == null) {
InputStream inputStream = plugin.getClass().getResourceAsStream(file);

if (inputStream == null) {
return new YamlConfiguration();
}

try (BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream(file), StandardCharsets.UTF_8))) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
FileConfiguration config = YamlConfiguration.loadConfiguration(reader);

if (defaults != null) {
Expand All @@ -269,7 +267,7 @@ private FileConfiguration streamConfigFile(@Nonnull String file, @Nullable FileC
return config;
} catch (IOException e) {
SlimefunPlugin.logger().log(Level.SEVERE, e, () -> "Failed to load language file into memory: \"" + file + "\"");
return null;
return new YamlConfiguration();
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/languages/af/categories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions src/main/resources/languages/af/messages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions src/main/resources/languages/af/recipes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions src/main/resources/languages/af/researches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions src/main/resources/languages/af/resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
48 changes: 24 additions & 24 deletions src/main/resources/languages/ar/categories.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
slimefun:
armor: الدروع
basic_machines: آلات بدائية
birthday: عيد ميلاد ذا بيزي بسكويت (26 أكتور)
cargo: إدارة الشحن
christmas: الكريسماس (ديسمبر)
easter: عيد الفصح (أبريل)
electricity: الطاقة والكهرباء
ender_talismans: تعويذات الإندر (المستوى الثاني)
food: طعام
gps: أجهزة الملاحة
halloween: الهالوين (31 أكتوبر)
items: عناصر مفيدة
magical_armor: الدروع السحرية
magical_gadgets: الأدوات السحرية
magical_items: العناصر السحرية
misc: عناصر منوعة
resources: موارد
talismans: التعويذات (المستوى الأول)
tech_misc: مكونات تقنية
technical_gadgets: أدوات تقنية
tools: الأدوات
valentines_day: عيد الحب (14 فبراير)
weapons: الأسلحة
androids: الروبوتات المبرمجة
weapons: 'الأسلحة'
tools: 'الأدوات'
items: 'عناصر مفيدة'
food: 'طعام'
basic_machines: 'آلات بدائية'
electricity: 'الطاقة والكهرباء'
androids: 'الروبوتات المبرمجة'
gps: 'أجهزة الملاحة'
armor: 'الدروع'
magical_items: 'العناصر السحرية'
magical_gadgets: 'الأدوات السحرية'
misc: 'عناصر منوعة'
technical_gadgets: 'أدوات تقنية'
resources: 'موارد'
cargo: 'إدارة الشحن'
tech_misc: 'مكونات تقنية'
magical_armor: 'الدروع السحرية'
talismans: 'التعويذات (المستوى الأول)'
ender_talismans: 'تعويذات الإندر (المستوى الثاني)'
christmas: 'الكريسماس (ديسمبر)'
valentines_day: 'عيد الحب (14 فبراير)'
easter: 'عيد الفصح (أبريل)'
birthday: 'عيد ميلاد ذا بيزي بسكويت (26 أكتور)'
halloween: 'الهالوين (31 أكتوبر)'
Loading

0 comments on commit 8a1eba8

Please sign in to comment.