You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+30
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,36 @@ Return value will be `null` if the language couldn't be detected.
93
93
94
94
Supported languages are listed in [Google API docs](https://cloud.google.com/translate/docs/languages).
95
95
96
+
### Preserving Parameters
97
+
98
+
The `preserveParameters()` method allows you to preserve certain parameters in strings while performing translations. This is particularly useful when dealing with localization files or templating engines where specific placeholders need to be excluded from translation.
99
+
100
+
Default regex is `/:(\w+)/` which covers parameters starting with `:`. Useful for translating language files of Laravel and other frameworks. You can also pass your custom regex to modify the parameter syntax.
101
+
102
+
```php
103
+
$tr = new GoogleTranslate('de');
104
+
105
+
$text = $tr->translate('Page :current of :total'); // Seite :aktuell von :gesamt
106
+
107
+
$text = $tr->preserveParameters()
108
+
->translate('Page :current of :total'); // Seite :current von :total
0 commit comments