Skip to content

Instantly share code, notes, and snippets.

@juukie
Created January 9, 2014 00:40
Show Gist options
  • Save juukie/8327427 to your computer and use it in GitHub Desktop.
Save juukie/8327427 to your computer and use it in GitHub Desktop.
Little Laravel / Symfony Translation playground
// app/lang/en/global.php
return array(
'apples' => '{0} Zero apples|one: Single apple|more: :count apples',
'beers' => '{0} Drama|Single beer|more: Cheers',
'soup' => '[-Inf,0] No soup|{1,2,5} One, two or five soups|[3,Inf] The amount of soup is :count',
);
// somewhere
trans_choice('global.apples', 0); // "Zero apple"
trans_choice('global.apples', 1); // "Single apple"
trans_choice('global.apples', 9); // "9 apples"
trans_choice('global.beers', 0); // "Drama"
trans_choice('global.beers', 1); // "Single beer"
trans_choice('global.beers', 20); // "Cheers"
trans_choice('global.soup', 0); // "No soup"
trans_choice('global.soup', 1); // "One, two or five soups"
trans_choice('global.soup', 2); // "One, two or five soups"
trans_choice('global.soup', 5); // "One, two or five soups"
trans_choice('global.soup', 4); // "The amount of soup is 4"
trans_choice('global.soup', 15); // "The amount of soup is 15"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment