vy_language_tag 0.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

Language Tag Representation #

LanguageTag is a class used for generating and checking language tags.

It can create a language Tag given all the subtags that are part of it or parsing an existing languageTag String.

The implementation is not yet complete, but it should be enough for the majority of cases

What is missing #

  • There is no control on the values inserted, except for the length (and position). This will be fixed in a future release.
  • The extension and private use subtags are not managed yet.

License

license.

Usage #

A simple usage example:

import 'package:vy_language_tag/vy_language_tag.dart';

main() {
  var languageTag = LanguageTag('en', region: 'US');
  print(languageTag.code);   // 'en-US'
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.1.5 #

  • Small fixes

0.1.4 #

  • Updated copyrights

0.1.3 #

  • Prepared example and README files for pub.
  • Corrected some Lint warnings

0.1.2 #

  • Added Methods toJson() and fromJson() to LanguageTag class.
  • Added Methods toJson() and fromJson() to Region class.

0.1.1 #

  • Deprecated "simpleCode()" method
  • Added "lowercaseCode()" method (substitutes "simpleCode()")
  • Added "lowercasePosix()" method (lowercase subtags separated by underscores).

0.1.0 #

  • Initial version

example/example.dart

/// Copyright © 2020 Giorgio Franceschetti. All rights reserved.

import 'package:vy_language_tag/vy_language_tag.dart';

void main() {
  var languageTag = LanguageTag('en');
  print(languageTag.code); // 'en'
  print(languageTag.posixCode); // 'en'
  print(languageTag.lowercaseCode); // 'en'
  print(languageTag.lowercasePosix); // 'en'

  languageTag = LanguageTag('en', region: 'US');
  print(languageTag.code); // 'en-US'
  print(languageTag.posixCode); // 'en_US'
  print(languageTag.lowercaseCode); // 'en-us'
  print(languageTag.lowercasePosix); // 'en_us'

  languageTag = LanguageTag('zh', script: 'hant', region: 'hk');
  print(languageTag.code); // 'zh-Hant-HK');
  print(languageTag.posixCode); // 'zh_Hant_HK');
  print(languageTag.lowercaseCode); // 'zh-hant-hk');
  print(languageTag.lowercasePosix); // 'zh_hant_hk');

  languageTag = LanguageTag.parse('en-us');
  print(languageTag.posixCode); // 'en_US');

  languageTag = LanguageTag.parse('de_CH_1901');
  print(languageTag.code); // 'de-CH-1901'
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  vy_language_tag: ^0.1.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:vy_language_tag/vy_language_tag.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.1 <3.0.0
vy_string_utils ^0.3.2 0.3.3
Dev dependencies
pedantic ^1.8.0
test ^1.6.0