pkg.re/essentialkaos/ek.10@v12.41.0+incompatible/pluralize/examples_test.go (about)

     1  package pluralize
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  //                                                                                    //
     5  //                         Copyright (c) 2022 ESSENTIAL KAOS                          //
     6  //      Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>     //
     7  //                                                                                    //
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  import (
    11  	"fmt"
    12  )
    13  
    14  // ////////////////////////////////////////////////////////////////////////////////// //
    15  
    16  func ExampleP() {
    17  	fmt.Println(P("I have %d %s", 1, "apple", "apples"))
    18  	fmt.Println(P("I have %d %s", 5, "apple", "apples"))
    19  	// Output: I have 1 apple
    20  	// I have 5 apples
    21  }
    22  
    23  func ExamplePS() {
    24  	fmt.Println(PS(Ru, "У меня %d %s", 1, "яблоко", "яблока", "яблок"))
    25  	fmt.Println(PS(Ru, "У меня %d %s", 5, "яблоко", "яблока", "яблок"))
    26  	// Output: У меня 1 яблоко
    27  	// У меня 5 яблок
    28  }
    29  
    30  func ExamplePluralize() {
    31  	fmt.Println(Pluralize(1, "apple", "apples"))
    32  	fmt.Println(Pluralize(5, "apple", "apples"))
    33  	// Output: apple
    34  	// apples
    35  }
    36  func ExamplePluralizeSpecial() {
    37  	fmt.Println(PluralizeSpecial(Ru, 1, "яблоко", "яблока", "яблок"))
    38  	fmt.Println(PluralizeSpecial(Ru, 5, "яблоко", "яблока", "яблок"))
    39  	// Output: яблоко
    40  	// яблок
    41  }