...

Source file src/golang.org/x/text/cmd/gotext/examples/rewrite/main.go

Documentation: golang.org/x/text/cmd/gotext/examples/rewrite

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"golang.org/x/text/language"
    11  	"golang.org/x/text/message"
    12  )
    13  
    14  func main() {
    15  	var nPizzas = 4
    16  	// The following call gets replaced by a call to the globally
    17  	// defined printer.
    18  	fmt.Println("We ate", nPizzas, "pizzas.")
    19  
    20  	p := message.NewPrinter(language.English)
    21  
    22  	// Prevent build failure, although it is okay for gotext.
    23  	p.Println(1024)
    24  
    25  	// Replaced by a call to p.
    26  	fmt.Println("Example punctuation:", "$%^&!")
    27  
    28  	{
    29  		q := message.NewPrinter(language.French)
    30  
    31  		const leaveAnIdentBe = "Don't expand me."
    32  		fmt.Print(leaveAnIdentBe)
    33  		q.Println() // Prevent build failure, although it is okay for gotext.
    34  	}
    35  
    36  	fmt.Printf("Hello %s\n", "City")
    37  }
    38  

View as plain text