Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ To use this class, you need to create translation files with your translated str

```ini
greeting = "Hello World!"
last_modified = "Last modified: %1$s!"
stringwithvars = "Hello %1$s! Last modified: %2$s!"

[category]
somethingother = "Something other..."
Expand All @@ -40,6 +42,8 @@ somethingother = "Something other..."

```ini
greeting = "Hallo Welt!"
last_modified = "Letzte Änderung: %1$s!"
stringwithvars = "Hallo %1$s! Letzte Änderung: %2$s!"

[category]
somethingother = "Etwas anderes..."
Expand Down Expand Up @@ -132,6 +136,9 @@ In this example, we use the translation string seen in step 1.

echo L::last_modified("today");
// Could be: 'Last modified: today'

echo L::stringwithvars("world", "today");
// Could be: 'Hello world! Last modified: today'

echo L($string);
// Outputs a dynamically chosen static property
Expand Down
10 changes: 9 additions & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@

<!-- Get some greetings -->
<p>A greeting: <?php echo L::greeting; ?></p>
<p>Something other: <?php echo L::category_somethingother; ?></p><!-- normally sections in the ini are seperated with an underscore like here. -->

<!-- Get last modified date -->
<p>Last modified: <?php echo L::last_modified("today"); ?></p>

<!-- A string with 2 variables -->
<p>A string with 2 variables: <?php echo L::stringwithvars("world", "today"); ?></p>

<!-- normally sections in the ini are seperated with an underscore like here. -->
<p>Something other: <?php echo L::category_somethingother; ?></p>
2 changes: 2 additions & 0 deletions lang/lang_de.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
greeting = "Hallo Welt!"
last_modified = "Letzte Änderung: %1$s!"
stringwithvars = "Hallo %1$s! Letzte Änderung: %2$s!"

[category]
somethingother = "Etwas anderes..."
2 changes: 2 additions & 0 deletions lang/lang_de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"greeting": "Hallo Welt!",
"last_modified": "Letzte Änderung: %1$s!",
"stringswithvars": "Hallo %1$s! Letzte Änderung: %2$s!",
"category": {
"somethingother": "Etwas anderes..."
}
Expand Down
2 changes: 2 additions & 0 deletions lang/lang_de.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
greeting: 'Hallo Welt!'
last_modified: 'Letzte Änderung: %1$s!'
stringswithvars: 'Hallo %1$s! Letzte Änderung: %2$s!'

category:
somethingother: 'Etwas anderes...'
2 changes: 2 additions & 0 deletions lang/lang_en.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
greeting = "Hello World!"
last_modified = "Last modified: %1$s!"
stringwithvars = "Hello %1$s! Last modified: %2$s!"

[category]
somethingother = "Something other..."
2 changes: 2 additions & 0 deletions lang/lang_en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"greeting": "Hello World!",
"last_modified": "Last modified: %1$s!",
"stringswithvars": "Hello %1$s! Last modified: %2$s!",
"category": {
"somethingother": "Something other..."
}
Expand Down
2 changes: 2 additions & 0 deletions lang/lang_en.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
greeting: 'Hello World!'
last_modified: 'Last modified: %1$s!'
stringswithvars: 'Hello %1$s! Last modified: %2$s!'

category:
somethingother: 'Something other...'