Dart library for some Turkish language specific operations.

Related tags

Templates turkish
Overview

turkish

This library provides these functions for Turkish language for Dart:

  • Converting strings to lower, upper and title case.
  • Regular and ignore case string sorting.

Some casing operations for Turkish does not work correctly in Dart core libraries because Dart uses default unicode mappings. Default case mappings fails for Turkish i->İ and I->ı conversions.

This library may not be necessary for Flutter or web projects if they use underlying system methods for locale specific text operations. But it can be handy when that is not the case.

Current implementation does not handle two code-unit variations. Complete special casing rules are defined here.

Usage

Add this line to pubspec.yaml:

turkish: '>=0.2.1'

Add this line to the import section:

import 'package:turkish/turkish.dart'

Extension methods

There are four extension methods that can be used for comparison and upper, lower and title casing.

import 'package:turkish/turkish.dart';

// Uses extension methods.
main() {
  // upperCaseTr
  var inputL = "kısa şiir";
  print("UpperCase for [$inputL]");
  print("Default = ${inputL.toUpperCase()}, "
      "Turkish = ${inputL.toUpperCaseTr()}\n");

  // lowerCaseTr
  var inputU = "KISA ŞİİR";
  print("LowerCase for [$inputU]");
  print("Default = ${inputU.toLowerCase()}, "
      "Turkish = ${inputU.toLowerCaseTr()}\n");

  // compareToTr
  var zonguldak = "Zonguldak";
  var cankiri = "Çankırı";
  print("Comparison for [$zonguldak] and [$cankiri]");
  print("Default = ${zonguldak.compareTo(cankiri)}, "
      "Turkish = ${zonguldak.compareToTr(cankiri)}\n");
}
Output:
UpperCase for [kısa şiir]
Default = KISA ŞIIR, Turkish = KISA ŞİİR

LowerCase for [KISA ŞİİR]
Default = kisa şiir, Turkish = kısa şiir

Comparison for [Zonguldak] and [Çankırı]
Default = -1, Turkish = 1

'turkish' object.

Also, for turkish specific sorting and casing a single object instance exposed from library called turkish can be used.

See also related Pub page.

Example:

import 'package:turkish/turkish.dart';

main() {
  // upperCaseTr
  var inputL = "kısa şiir";
  print("UpperCase for [$inputL]");
  print("Default = ${inputL.toUpperCase()}, "
      "Turkish = ${turkish.toUpperCase(inputL)}\n");

  // lowerCaseTr
  var inputU = "KISA ŞİİR";
  print("LowerCase for [$inputU]");
  print("Default = ${inputU.toLowerCase()}, "
      "Turkish = ${turkish.toLowerCase(inputU)}\n");

  // compareToTr
  var zonguldak = "Zonguldak";
  var cankiri = "Çankırı";
  print("Comparison for [$zonguldak] and [$cankiri]");
  print("Default = ${zonguldak.compareTo(cankiri)}, "
      "Turkish = ${zonguldak.compareToTr(cankiri)}\n");

  // sort Default
  var list = ["Az", "ağ", "aç", "ad"];
  print("Input = $list");
  print("Default Sort = ${list..sort()}");

  // sort Turkish  
  list = ["Az", "ağ", "aç", "ad"];
  print("Turkish Sort = ${list..sort(turkish.comparator)}");

  // sort Turkish ignore case  
  list = ["Az", "ağ", "aç", "ad"];
  print("Turkish Sort Ignore Case = "
      "${list..sort(turkish.comparatorIgnoreCase)}");
}
Output:
UpperCase for [kısa şiir]
Default = KISA ŞIIR, Turkish = KISA ŞİİR

LowerCase for [KISA ŞİİR]
Default = kisa şiir, Turkish = kısa şiir

Comparison for [Zonguldak] and [Çankırı]
Default = -1, Turkish = 1

Input = [Az, ağ, aç, ad]
Default Sort = [Az, ad, aç, ağ]
Turkish Sort = [Az, aç, ad, ağ]
Turkish Sort Ignore Case = [aç, ad, ağ, Az]
You might also like...

Implementing simple storage operations, CRUD (Create, Read, Update, Delete), using Firebase Firestore

Implementing simple storage operations, CRUD (Create, Read, Update, Delete), using Firebase Firestore

CRUD Firebase Implementing simple storage operations, CRUD (Create, Read, Update

Oct 29, 2022

A shopper Flutter app that use BloC pattern and CRUD operations with different ways(memory/sqlite/http)

A shopper Flutter app that use BloC pattern and CRUD operations with different ways(memory/sqlite/http)

The project is maintained by a non-profit organisation, along with an amazing collections of Flutter samples. We're trying to make continuous commits

Nov 10, 2022

A flutter demo app to practice Map data structure and its common operations

Map Operations A flutter demo app to practice Map data structure and its common operations Developer Alexander Sosa (https://www.linkedin.com/in/alexa

Jan 3, 2022

Boolean operations on polygons (union, intersection, difference, xor)

poly_bool_dart Boolean operations on polygons (union, intersection, difference, xor) (this library is a port for flutter of polybooljs Features Clips

Jan 6, 2023

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.

Nov 26, 2022

Multi-platform application to practice quizzes from the course Operations Research M.

Multi-platform application to practice quizzes from the course Operations Research M.

Dec 26, 2022

A Flutter Task App with Parse (Back4app) as the backend demonstrating CRUD operations.

A Flutter Task App with Parse (Back4app) as the backend demonstrating CRUD operations.

Siro's Task App Description A Flutter Task App with Parse (Back4app) as the backend demonstrating CRUD operations. Getx State Management Objective Thi

Aug 27, 2022

Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line.

flutter_distributor Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line. The flutter_distributor source

Dec 24, 2022

ESP-Touch Dart API for Flutter. Platform-specific implementation for Android (Java) and iOS (Objective-C).

ESP-Touch Dart API for Flutter. Platform-specific implementation for Android (Java) and iOS (Objective-C).

esptouch_flutter Flutter plugin for ESP-Touch to configure network for ESP-8266 and ESP-32 devices. Runs on iOS and Android. esptouch_flutter is Flutt

Dec 10, 2022
Comments
  • 0.2.1 Add String extension method compareToTr

    0.2.1 Add String extension method compareToTr

    First of all, thanks for great library.

    The idea of exposing comparators is great but it is useful only if you have string list to sort.

    I needed to sort a complex list based on a property value. Therefore, i needed compareTr function of yours which is private. In this PR, i have added a compareToTr extension method to String class.

    opened by uyarburak 2
Owner
Ahmet A. Akın
Developer and father of two.
Ahmet A. Akın
End to end flutter series for zero to hero flutter devloper.( lang of videos is turkish)

flutter_full_learn A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Veli Bacik 191 Dec 24, 2022
This project provides an amazing widget for using the specific inputfield for the specific platform

This project provides an amazing widget for using the specific inputfield for the specific platform

Kovács Levente 0 Apr 12, 2022
The domain specific language in dart for flutter widgets.

Rettulf !esrever ni stegdiw etirW Getting started import 'package:rettulf/rettulf.dart'; void main() => const MyApp().runAsApp(); class MyApp extend

Li plum 4 Dec 21, 2022
This is a command-line app written on dart language for flutter applications that will help you to generate some boilerplate code

dart-generator Manual installation: 1- generate a platform executable from code dart compile exe main.dart -o generator this will generate a new gene

One Studio 11 Oct 26, 2022
Flutter language pickers2 - Language pickers package for Dart and Flutter

language_pickers2 Notes: Original repository from github.com/gomgom, unfortunate

Charles Dyason 0 Feb 6, 2022
FIDL(Flutter Interface Definition Language) is a language for transfer objects cross platforms.

Flutter Interface Definition Language (FIDL) README in English(TODO) FIDL 即 Flutter 接口定义语言,类似于AIDL(Android Interface Definition Language)。您可以利用它定义不同平台

null 47 Dec 7, 2022
null 1 Jan 8, 2022
A Mobile application developed with Flutter and Dart to do math operations with binary numbers.

Math operations with Binary Numbers Readme PT About this Project Mobile application developed with Flutter and Dart to do math operations as sum, subt

Manoel Ribeiro 3 Nov 3, 2020
A library that exposes device specific speech recognition capability

speech_to_text A library that exposes device specific speech recognition capability. This plugin contains a set of classes that make it easy to use th

null 0 Apr 24, 2022
A Flutter application that demonstrate simple CRUD operations with Firebase cloud database.

Cricket Team A Flutter application that demonstrate simple CRUD operations with Firebase cloud database. Preview Home Empty Swipe Add Player Update Pl

Bhavik Makwana 45 Jun 19, 2021