Skip to content

Commit dea5b8c

Browse files
committed
Fix class name and template call
1 parent 63a987b commit dea5b8c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

development/language/usage.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ Using the Language System in php
2222
================================
2323

2424
The object holding the language dictionary for the current user is the ``$user``
25-
object (``phpbb\user`` class). To get the translation of a language entry inside
26-
of php code, call the ``phpbb\user::lang()`` method:
25+
object (``phpbb\language\language`` class). To get the translation of a language
26+
entry inside of php code, call the ``phpbb\language\language::lang()`` method:
2727

2828
.. code-block:: php
2929
30-
$user->lang('LANG_KEY');
30+
$language->lang('LANG_KEY');
3131
3232
You can also insert values into translated string. Use ``%s`` as placeholders
3333
for string in the language string and ``%d`` for integers:
3434

3535
.. code-block:: php
3636
3737
// Language string: "My translation has a %s"
38-
echo $user->lang('LANG_KEY', 'parameter');
38+
echo $language->lang('LANG_KEY', 'parameter');
3939
// Output: "My translation has a parameter"
4040
4141
// Language string: "My translation has %d parameter"
42-
echo $user->lang('LANG_KEY', 1);
42+
echo $language->lang('LANG_KEY', 1);
4343
// Output: "My translation has 1 parameter"
4444
4545
.. warning::
@@ -55,13 +55,14 @@ for string in the language string and ``%d`` for integers:
5555
The dictionary is not loaded into memory all at once, but is split up in several
5656
files, which have to be manually loaded on demand. The files are stored inside
5757
the language directory, named after its
58-
`language tag <https://area51.phpbb.com/docs/31x/coding-guidelines.html#translation>`_,
58+
`language tag <https://area51.phpbb.com/docs/master/coding-guidelines.html#translation>`_,
5959
where one subdirectory is used for each installed language. The default language
6060
files are in the root of that subdirectory, while ACP language files go into the
6161
``/acp`` subdirectory; email templates are placed in the ``/email``
6262
subdirectory.
6363

6464
.. note::
65+
6566
Files for extensions should be placed in the extension's ``/language``
6667
directory.
6768

@@ -84,22 +85,22 @@ pass the name with the subdirectory but without extension as argument of setup.
8485
$user->setup(array('ucp', 'search'));
8586
8687
Since ``phpbb\user::setup()`` must only be called once,
87-
``phpbb\user::add_lang()`` has to be used, to load additional language files,
88-
after ``phpbb\user::setup()`` has already been called.
88+
``phpbb\language\language::add_lang()`` has to be used, to load additional
89+
language files, after ``phpbb\user::setup()`` has already been called.
8990

9091
Loading from an extension
9192
-------------------------
9293

9394
To load a file from an extension
94-
you need to use ``phpbb\user::add_lang_ext()`` which takes
95+
you need to use ``phpbb\language\language::add_lang_ext()`` which takes
9596
the vendor + extension name as first argument and the array of language files as
9697
a second argument.
9798

9899
.. code-block:: php
99100
100-
$user->add_lang_ext('acme/demo', 'demo');
101+
$language->add_lang('demo', 'acme/demo');
101102
// or
102-
$user->add_lang_ext('acme/demo', array('demo', 'demo2'));
103+
$language->add_lang(array('demo', 'demo2'), 'acme/demo');
103104
104105
Using the Language System in template files
105106
===========================================

0 commit comments

Comments
 (0)