From 8c411b4e7d712d774ce7a4c8f2f3f1f572f1dbd9 Mon Sep 17 00:00:00 2001 From: Tom Haskins-Vaughan Date: Mon, 14 Mar 2016 11:50:48 -0400 Subject: [PATCH 1/4] Adding formatting examples to README --- README.md | 23 +++++++++++++++++++++++ src/Locale.php | 13 ++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 79e6e0a..f308989 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,29 @@ echo Locale::fromCountrySlashLanguage('ca/fr'); // fr_CA ``` +### Formatting + +Use: + +- `%L` For uppercase language code +- `%l` For lowercase language code +- `%C` For uppercase country code +- `%c` For lowercase country code + +Note: + +- * any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \ +- * To get a \ You will need to double escape ( \\\ ) + +Examples: + +```php +echo Locale::fromString('se_FI')->format('%L_%c'); // SE_fi +echo Locale::fromString('se_FI')->format('%C/%s'); // FI/se +echo Locale::fromString('se_FI')->format('%c/%s'); // fi/se +echo Locale::fromString('se_FI')->format('%c\\\%s'); // fi\se +``` + ## Installation ``` diff --git a/src/Locale.php b/src/Locale.php index 2ba45a9..53938a8 100644 --- a/src/Locale.php +++ b/src/Locale.php @@ -149,16 +149,15 @@ public static function fromCountrySlashLanguage($countrySlashLanguage) } /** - * From countryCode/languageCode + * Format Locale as string * - * The use of this code is as follows: - * $locale = Locale::fromString('se_FI'); - * 'SE_fi' == $locale->format('%L_%c'); - * 'FI/se' == $locale->format('%C/%s'); - * 'fi/se' == $locale->format('%c/%s'); - * 'fi\se' == $locale->format('%c\\\%s'); + * echo Locale::fromString('se_FI')->format('%L_%c'); // SE_fi + * echo Locale::fromString('se_FI')->format('%C/%s'); // FI/se + * echo Locale::fromString('se_FI')->format('%c/%s'); // fi/se + * echo Locale::fromString('se_FI')->format('%c\\\%s'); // fi\se * * Current translattable codes are: + * * * %L For uppercase language code * * %l For lowercase language code * * %C For uppercase country code From ce02a2f419a8a5fa84d0e18f3eab06ba83ea09bc Mon Sep 17 00:00:00 2001 From: Tom Haskins-Vaughan Date: Mon, 14 Mar 2016 11:51:45 -0400 Subject: [PATCH 2/4] Typo --- src/Locale.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Locale.php b/src/Locale.php index 53938a8..177bd66 100644 --- a/src/Locale.php +++ b/src/Locale.php @@ -156,7 +156,7 @@ public static function fromCountrySlashLanguage($countrySlashLanguage) * echo Locale::fromString('se_FI')->format('%c/%s'); // fi/se * echo Locale::fromString('se_FI')->format('%c\\\%s'); // fi\se * - * Current translattable codes are: + * Current formatting codes are: * * * %L For uppercase language code * * %l For lowercase language code From 51a871f6dd692dda17642b5bdc96f585aa7dd8d2 Mon Sep 17 00:00:00 2001 From: Tom Haskins-Vaughan Date: Mon, 14 Mar 2016 11:53:00 -0400 Subject: [PATCH 3/4] Typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f308989..d6e04e4 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ Use: Note: -- * any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \ -- * To get a \ You will need to double escape ( \\\ ) +- any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \ +- to get a \ You will need to double escape ( \\\ ) Examples: From 5abdfd5f95a303f06f2a28f97d43ff2327d672a1 Mon Sep 17 00:00:00 2001 From: Tom Haskins-Vaughan Date: Mon, 14 Mar 2016 11:53:46 -0400 Subject: [PATCH 4/4] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d6e04e4..56c63fc 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Use: Note: - any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \ -- to get a \ You will need to double escape ( \\\ ) +- to get a `\` You will need to double escape ( `\\\` ) Examples: