पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv1.6.0

yaml_localizations

LocalizationsDelegate पर आधारित एक न्यूनतम YAML स्थानीयीकरण पैकेज।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
33
लाइक
2
Pub अंक
150

पैकेज इंस्टॉल करें

flutter pub add yaml_localizations

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

एक हल्का फ्लटर पैकेज जो YAML फ़ाइलों के उपयोग से ऐप अनुवाद प्रबंधित करता है, जो फ्लटर के LocalizationsDelegate पर आधारित है। यह YAML संसाधनों से स्थानीयीकृत डेटा लोड करके आसान अंतरराष्ट्रीयकरण सुनिश्चित करता है, जिससे बहुभाषी समर्थन के लिए जटिल सेटअप की आवश्यकता नहीं होती है। यह पैकेज सभी मुख्य प्लेटफॉर्मों पर फ्लटर ऐप्स में बिना किसी बाधा के एकीकृत होता है, न्यूनतम बॉयलरप्लेट के साथ स्पष्ट और बनाए रखने योग्य तरीके से स्थानीयीकरण का प्रबंधन करता है। जटिल JSON-आधारित या कोड में लिखे गए अनुवाद प्रणालियों के बजाय सरल विकल्प चाहने वाले विकासकर्ताओं के लिए आदर्श है।

उपयोग

  • बहुभाषी ऐप समर्थन
  • सरल अनुवाद प्रबंधन
  • मौजूदा Flutter प्रोजेक्ट्स के साथ एकीकरण
  • हल्का स्थानीयकरण समाधान
  • डायनामिक भाषा स्विचिंग

मुख्य विशेषताएँ

  • YAML आधारित अनुवाद फ़ाइलें
  • LocalizationsDelegate पर आधारित
  • प्लेटफॉर्म के अनुकूलता
  • न्यूनतम कॉन्फ़िगरेशन
  • आसानी से विस्तारित और बनाए रखा जा सकता है

इनके लिए उपयुक्त

  • छोटे से मध्यम आकार के एप्लिकेशन
  • JSON के बजाय YAML पसंद करने वाले विकासकर्मी
  • त्वरित i18n सेटअप की आवश्यकता वाले प्रोजेक्ट
  • जटिल स्थानीयकरण फ्रेमवर्क से बचने वाली टीमें
  • कई प्लेटफॉर्म के लिए लक्षित ऐप्स

विचार योग्य बातें

  • हाथ से YAML फ़ाइल प्रबंधन की आवश्यकता है
  • कोई निर्मित अनुवाद संपादन उपकरण नहीं
  • स्ट्रिंग-आधारित अनुवादों पर सीमित
  • बड़े पैमाने पर अनुवाद कार्यप्रणाली के लिए आदर्श नहीं
  • कोई रनटाइम अनुवाद अपडेट नहीं

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

yaml_localizations

A minimal YAML localization package for Flutter.

YAML is a human-readable, configuration file format with a minimal syntax, which allows you to represent strings as key/value pairs in addition to other types.

YAML is the format used by Flutter's pubspec.yaml file.

Install

Add yaml_localizations and flutter_localizations as dependencies to your pubspec.yaml.

dependencies:
  flutter_localizations:
    sdk: flutter
  yaml_localizations:
Add a YAML file per language

Add a YAML file per language you support in an asset path and describe it in your pubspec.yaml

flutter:
  assets:
    - assets/yaml_translations/

The YAML file name must match the language tag described in supportedLocales.

E.g. Locale('en', 'US') must have a corresponding assetPath/en-US.yaml file.

Add localizationDelegates and supportedLocales

Add YamlLocalizationsDelegate to MaterialApp and set supportedLocales using language/country codes.

MaterialApp(
  localizationsDelegates: [
    // global delegates
    ...GlobalMaterialLocalizations.delegates,
    // yaml localizations
    YamlLocalizationsDelegate(path: 'assets/yaml_translations'),
  ],
  supportedLocales: [
    Locale('en', 'GB'),
    Locale('en', 'US'),
    Locale('en'),
    Locale('nb'),
  ],
}

Note on iOS

Add supported languages to ios/Runner/Info.plist as described here.

Example:

<key>CFBundleLocalizations</key>
<array>
	<string>en-GB</string>
	<string>en</string>
	<string>nb</string>
</array>

YAML format

Hi: Hi
Text: |
  There once was a tall man from Ealing
  Who got on a bus to Darjeeling
      It said on the door
      "Please don't sit on the floor"
  So he carefully sat on the ceiling
Long: >
  Wrapped text
  will be folded
  into a single
  paragraph

  Blank lines denote
  paragraph breaks

Tip: Yaml supports several ways of expressing strings. Use the vertical bar character to indicate that a string will span several lines. Use the greater-than character to break up long lines.

API

Translate strings using

YamlLocalizations.of(context)?.string('Hi')

We keep the API simple, but you can easily add an extension method to String like this:

extension LocalizedString on String {
  String tr(BuildContext context) => YamlLocalizations.of(context)!.string(this);
}

So you can use it like this:

'Hi'.tr(context)

Example

See example

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 1 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।