Skip to content

Commit

Permalink
readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
wUFr committed Dec 5, 2024
1 parent ec3cbef commit 7acf226
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,31 @@ $l = new wUFr\Translator(dir: "./locales/", lang: "en_US");
echo $l->locale(
"someFolder/testValues",
"translate_this"
) // outputs "translated value"
)
// outputs "translated value"


// STRING BASED ON "AMOUNT" OF SOMETHING
echo $l->locale(
"someFolder/testValues",
"BasedOnNumber",
["_counter" => 0]
) // outputs "box"
)
// outputs "box"

echo $l->locale(
"someFolder/testValues",
"BasedOnNumber",
["_counter" => 50]
) // outputs "a lot of boxes"
)
// outputs "a lot of boxes"

echo $l->locale(
"someFolder/testValues",
"BasedOnNumber",
["_counter" => 51]
) // outputs "a lot of boxes" as well
)
// outputs "a lot of boxes" as well


// STRING WITH REPLACABLE VALUES (IDEAL FOR USE IN TEMPLATING ENGINES, SO YOU DONT HAVE TO SPLIT TEXT INTO MULTIPLE KEY-STRINGS IN CONFIG)
Expand All @@ -97,11 +101,18 @@ echo $l->locale(
"username" => "John Doe",
"product" => "AMD Epyc Server"
]
) // outputs "Thank you John Doe for buying AMD Epyc Server"
)
// outputs "Thank you John Doe for buying AMD Epyc Server"

/*
CAN BE COMBINED WITH COUNTER AS WELL

WARNING: "_counter" cant be used in replacable values, you always have to specify it again

its only used to decide which string should be returned, not for replacint

*/

// CAN BE COMBINED WITH COUNTER AS WELL
// WARNING: "_counter" cant be used in replacable values, you always have to specify it again
// its only used to decide which string should be returned, not for replacint
echo $l->locale(
"someFolder/testValues",
"thxTextCounter",
Expand All @@ -111,5 +122,6 @@ echo $l->locale(
"username" => "John Doe",
"product" => "AMD Epyc Server"
]
) // outputs: "Thank you John Doe for buying 50 pieces of AMD Epyc Server"
```
)
// outputs: "Thank you John Doe for buying 50 pieces of AMD Epyc Server"
```

0 comments on commit 7acf226

Please sign in to comment.