Update locales/README.rst
This commit is contained in:
parent
76453bb155
commit
4779b66af1
2 changed files with 21 additions and 10 deletions
|
|
@ -7,7 +7,7 @@ from ytmusicapi.ytmusic import YTMusic # noqa: E402
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
config.read('./test.cfg', 'utf-8')
|
config.read('./test.cfg', 'utf-8')
|
||||||
|
|
||||||
youtube = YTMusic(language='de')
|
youtube = YTMusic()
|
||||||
youtube_auth = YTMusic(config['auth']['headers_file'])
|
youtube_auth = YTMusic(config['auth']['headers_file'])
|
||||||
youtube_brand = YTMusic(config['auth']['headers'], config['auth']['brand_account'])
|
youtube_brand = YTMusic(config['auth']['headers'], config['auth']['brand_account'])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,40 @@
|
||||||
Translations
|
Translations
|
||||||
============================================
|
============================================
|
||||||
Translations use the Linux command line utility xgettext, which you can install for example using your package manager.
|
Translations are required for ytmusicapi since it relies on parsing user interface text.
|
||||||
|
In some places, for example the search() or get_artist() features, there is no other way to tell which content type is
|
||||||
|
offered other than parsing display text, which depends on the user's language. Changing the API language is desirable,
|
||||||
|
since artist and song titles are also language dependent.
|
||||||
|
|
||||||
|
This package uses the Linux command line utility xgettext, which you can install for example using your package manager.
|
||||||
|
|
||||||
Add new translatable texts from code
|
Add new translatable texts from code
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
xgettext -d base -o locales/base.pot ytmusicapi/*.py
|
``xgettext -d base -o locales/base.pot ytmusicapi/*.py``
|
||||||
sed --in-place locales/base.pot --expression=s/CHARSET/UTF-8/
|
|
||||||
|
``sed --in-place locales/base.pot --expression=s/CHARSET/UTF-8/``
|
||||||
|
|
||||||
Create new translation
|
Create new translation
|
||||||
----------------------
|
----------------------
|
||||||
mkdir -p locales/{en,es}/LC_MESSAGES
|
Create the directories (in this case for English, Spanish):
|
||||||
cp locales/base.pot locales/LANG/LC_MESSAGES/base.po
|
|
||||||
|
``mkdir -p locales/{en,es}/LC_MESSAGES``
|
||||||
|
|
||||||
|
Copy the base template:
|
||||||
|
|
||||||
|
``cp locales/base.pot locales/LANG/LC_MESSAGES/base.po``
|
||||||
|
|
||||||
Update translation
|
Update translation
|
||||||
----------------
|
------------------
|
||||||
|
|
||||||
msgmerge --update locales/de/LC_MESSAGES/base.po locales/base.pot
|
``msgmerge --update locales/de/LC_MESSAGES/base.po locales/base.pot``
|
||||||
|
|
||||||
Edit translation
|
Edit translation
|
||||||
----------------
|
----------------
|
||||||
You can use POEdit
|
You can use POEdit or edit the .po file manually
|
||||||
|
|
||||||
Finalize translation
|
Finalize translation
|
||||||
---------------------
|
---------------------
|
||||||
To generate mo files, run
|
To generate mo files, run
|
||||||
|
|
||||||
msgfmt -o locales/de/LC_MESSAGES/base.mo locales/de/LC_MESSAGES/base
|
``msgfmt -o locales/de/LC_MESSAGES/base.mo locales/de/LC_MESSAGES/base``
|
||||||
Loading…
Reference in a new issue