Unterstützte Dateitypen (Strings)

.JSON - React-Intl Simple (Strings)

Inhalte werden von Phrase Language AI maschinell aus dem Englischen übersetzt.

Dateierweiterungen

.json

API-Erweiterung

react_simple_json

Import

Ja

Exportieren

Ja

Unterstützung für Pluralformen

Ja

Unterstützung für Beschreibungen

Ja, mit Standard-Nachrichtenextraktion.

React-Intl ist eine JavaScript-Bibliothek zur Vereinfachung der Internationalisierung (i18n) und (Lokalisierung) vor allem für in React entwickelte Anwendungen. React-Intl verwendet standardmäßig .js-Dateien zum Speichern der lokalisierten Inhalte. Lokalisierte Inhalte werden in eine standardisierte .JSON-Datei (React-Intl Simple JSON) ausgekoppelt, auf die im Ausgangscode verwiesen wird.

Wenn du verschachtelte Nachrichten verwendest, verwende das Format React-Intl Nested JSON. Dies ist in React-Intl v2 nicht mehr zeitgemäß.

KI-Chatbots können sehr effektiv beim Erstellen einer Liste von Keys aus einer .JSON-Datei sein.

Codebeispiel

{
  "boolean_key": "--- true\n",
  "empty_string_translation": "",
  "key_with_description": "Check it out! This key has a description! (At least in some formats)",
  "key_with_line-break": "This translations contains\na line-break.",
  "nested.deeply.key": "I'm a deeply nested key.",
  "nested.key": "This key is nested inside a namespace.",
  "null_translation": null,
  "pluralized_key.one": "Only one kitten found.",
  "pluralized_key.other": "Wow, you have %s kittens!",
  "pluralized_key.zero": "You have no kittens.",
  "sample_collection": [
    "first item",
    "second item",
    "third item"
  ],
  "simple_key": "Simple key, simple message, so simple.",
  "unverified_key": „Diese Übersetzung ist noch nicht überprüft und wartet darauf. (In some formats we also export this status)"
}

Verwendung von React-Intl

Übersetzungen befinden sich normalerweise in einer .js-Datei:

module.exports = {
    "locales": ["en-US"],
    "messages": {
        "hello" : "World",
        other_hello : 'Other World',
    },
    "formats": {}
};

Verschiebe Nachrichten in eine separate Sprachdatei, z.B. en-US.json:

{
    "hello" : "World",
    other_hello : 'Other World',
}

Stelle sicher, dass Nachrichten gültige .JSON-Syntax haben:

{
    "hello" : "World",
    "other_hello" : "Other World"
}

Füge die Nachrichten mit einer Require-Anweisung hinzu:

module.exports = {
    "locales": ["en-US"],
    "messages": require('./en-US.json'),
    "formats": {}
};

Das React-Intl Simple JSON-Format kann jetzt verwendet werden, um React-Intl-Sprachdateien hochzuladen / herunterzuladen.

Plurale für JSON-Dateien

Das gängigste Format für Plural-Key-Nachrichten in verschiedenen Bibliotheken:

"messages": {
    "one": "One message received.",
    "other": "%s messages received.",
    "zero": "No messages received."
}
War dieser Beitrag hilfreich?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.