Skip to content

Commit

Permalink
Translate comments in L.java #393
Browse files Browse the repository at this point in the history
  • Loading branch information
smehrbrodt committed Sep 22, 2022
1 parent 5d5caab commit 271dc45
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions core/src/main/java/de/muenchen/allg/itd51/wollmux/util/L.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
import de.muenchen.allg.itd51.wollmux.config.ConfigThingy;

/**
* Funktionen zur Lokalisierung.
*
* @author Matthias Benkmann (D-III-ITD D.10)
* Localization functions
*/
public class L
{
Expand All @@ -44,8 +42,7 @@ public class L
private static StringBuilder debugMessages;

/**
* Wird für die aktuelle Sprache initialisiert und bildet einen Originalstring auf
* einen übersetzten String ab.
* Initialized for the current language and maps an original string to a translated string.
*/
private static final Map<String, String> mapMessageToTranslation =
new HashMap<>();
Expand All @@ -54,8 +51,8 @@ private L()
{}

/**
* Falls für original eine Übersetzung verfügbar ist, wird diese zurückgeliefert,
* ansonsten der Originalstring.
* If a translation is available for original, it will be returned,
* otherwise the original string.
*/
public static String m(String original)
{
Expand All @@ -67,49 +64,44 @@ public static String m(String original)
}

/**
* Falls für original eine Übersetzung verfügbar ist, wird diese zurückgeliefert,
* ansonsten der Originalstring. Dabei werden alle Vorkommen von "%1" durch
* insertion1 ersetzt.
* If a translation is available for original, it will be returned,
* otherwise the original string.
* All occurrences of "%1" will be replaced by insertion1.
*/
public static String m(String original, Object insertion1)
{
// nicht replaceAll verwenden, weil es \ und $ besonders
// interpretiert
// do not use replaceAll because it interprets \ and $ specially
return replace(m(original), "%1", "" + insertion1);
}

/**
* Falls für original eine Übersetzung verfügbar ist, wird diese zurückgeliefert,
* ansonsten der Originalstring. Dabei werden alle Vorkommen von "%1" durch
* insertion1 und von "%2" durch insertion2 ersetzt.
* If a translation is available for original, it will be returned,
* otherwise the original string.
* All occurrences of "%1" will be replaced by insertion1 and of "%2" by insertion2.
*/
public static String m(String original, Object insertion1, Object insertion2)
{
// nicht replaceAll verwenden, weil es \ und $ besonders
// interpretiert
// do not use replaceAll because it interprets \ and $ specially
return replace(m(original, insertion1), "%2", "" + insertion2);
}

public static String m(String original, Object insertion1, Object insertion2,
Object insertion3)
{
// nicht replaceAll verwenden, weil es \ und $ besonders
// interpretiert
// do not use replaceAll because it interprets \ and $ specially
return replace(m(original, insertion1, insertion2), "%3", "" + insertion3);
}

public static String m(String original, Object insertion1, Object insertion2,
Object insertion3, Object insertion4)
{
// nicht replaceAll verwenden, weil es \ und $ besonders
// interpretiert
// do not use replaceAll because it interprets \ and $ specially
return replace(m(original, insertion1, insertion2, insertion3), "%4", ""
+ insertion4);
}

/**
* Ersetzt in where alle Vorkommen von what durch withWhat und liefert das Ergebnis
* zurück.
* Replaces in where all occurrences of what by withWhat and returns the result returned.
*/
private static String replace(String where, String what, String withWhat)
{
Expand All @@ -129,16 +121,15 @@ private static String replace(String where, String what, String withWhat)
}

/**
* Liefert alle während der Initialisierung aufgelaufenen Debug-Messages zurück und
* gibt dann ihren Speicher frei.
* Returns all debug messages accumulated during initialization and then releases their memory.
*/
public static String flushDebugMessages()
{
String str;
if (debugMessages != null)
{
str = debugMessages.toString();
debugMessages = null; // Speicher freigeben
debugMessages = null; // Free memory
}
else
str = "";
Expand All @@ -147,10 +138,10 @@ public static String flushDebugMessages()
}

/**
* Initialisiert die Übersetzungs-Map mit l10n.
* Initializes the translation map with l10n.
*
* @param l10n
* ein beliebiger Knoten mit "L10n"-Unterknoten.
* any node with "L10n" subnodes.
*/
public static void init(ConfigThingy l10n)
{
Expand Down

0 comments on commit 271dc45

Please sign in to comment.