Tipi di file supportati (Strings)

.JSON - React-Intl Simple (Strings)

Contenuti tradotti automaticamente dall'inglese con Phrase Language AI.

Estensioni dei file

.json

Estensione API

react_simple_json

Importa

Esporta

Supporto forme plurali

Supporto descrizione

Sì, con estrazione dei messaggi predefinita.

React-Intl è una libreria JavaScript progettata per semplificare l'internazionalizzazione (i18n) e la localizzazione principalmente per le applicazioni sviluppate in React. Per impostazione predefinita, React-Intl utilizza i file .js per memorizzare il contenuto localizzato. Il contenuto localizzato viene separato in un file .JSON standardizzato (JSON sempice React-Intl) per essere referenziato nel codice origine.

Se si utilizzano messaggi nidificati, usa il formato React-Intl Nested JSON. Questo è obsoleto in React Intl v2.

I chatbot IA possono essere molto efficaci nel generare un elenco di chiavi da un file .JSON.

Campione di codice

{
  "boolean_key": "--- true\n",
  "empty_string_translation": "",
  "chiave_con_descrizione": "Dai un'occhiata!" Questa chiave ha una descrizione! (Almeno in alcuni formati)",
  "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.",
  "chiave_non_verificata": "Questa traduzione non è ancora verificata e resta in attesa." (In alcuni formati esportiamo anche lo stato)"
}

Utilizzo di React Intl

Le traduzioni risiedono normalmente in un file .js:

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

Sposta i messaggi in un file di impostazioni locali separato, ad es. en-US.json:

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

Assicurati che i messaggi abbiano una sintassi .JSON valida:

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

Includi nei messaggi un’istruzione di require:

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

Il formato JSON semplice React-Intl può ora essere utilizzato per caricare/scaricare file di impostazioni locali React Intl.

Plurali per file JSON

Il formato più comune di messaggi di chiavi plurali su varie librerie:

"messages": {
    "one": "One message received.",
    "other": "%s messaggi ricevuti.",
    "zero": "No messages received."
}
Questo articolo ti è stato utile?

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.