diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f29729..04a1cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,200 +1,16 @@ # Changelog -## [V0.0.7a1](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.7a1) (2023-12-29) +## [V0.0.8a2](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.8a2) (2023-12-29) -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a24...V0.0.7a1) - -## [V0.0.6a24](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a24) (2023-12-28) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a23...V0.0.6a24) - -**Merged pull requests:** - -- refactor/bus\_utils [\#68](https://github.com/OpenVoiceOS/ovos-bus-client/pull/68) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a23](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a23) (2023-12-28) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a22...V0.0.6a23) - -**Merged pull requests:** - -- feat/gui\_bus\_api [\#67](https://github.com/OpenVoiceOS/ovos-bus-client/pull/67) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a22](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a22) (2023-12-28) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a21...V0.0.6a22) - -**Merged pull requests:** - -- feat/bus\_apis [\#66](https://github.com/OpenVoiceOS/ovos-bus-client/pull/66) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a21](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a21) (2023-12-14) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a20...V0.0.6a21) - -**Merged pull requests:** - -- Update to stable dependency specs [\#65](https://github.com/OpenVoiceOS/ovos-bus-client/pull/65) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [V0.0.6a20](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a20) (2023-12-08) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a19...V0.0.6a20) - -**Implemented enhancements:** - -- feat/tts\_prefs [\#64](https://github.com/OpenVoiceOS/ovos-bus-client/pull/64) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a19](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a19) (2023-10-25) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a18...V0.0.6a19) - -**Merged pull requests:** - -- Improved session logging [\#62](https://github.com/OpenVoiceOS/ovos-bus-client/pull/62) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [V0.0.6a18](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a18) (2023-10-24) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a17...V0.0.6a18) - -**Merged pull requests:** - -- remove deprecated [\#61](https://github.com/OpenVoiceOS/ovos-bus-client/pull/61) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a17](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a17) (2023-10-24) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a16...V0.0.6a17) - -**Fixed bugs:** - -- fix/init\_of\_context\_manager [\#60](https://github.com/OpenVoiceOS/ovos-bus-client/pull/60) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a16](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a16) (2023-10-23) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a15...V0.0.6a16) - -**Fixed bugs:** - -- fix/huge\_integer\_error [\#58](https://github.com/OpenVoiceOS/ovos-bus-client/pull/58) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a15](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a15) (2023-10-23) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a14...V0.0.6a15) - -**Fixed bugs:** - -- rm/valid\_langs\_session [\#57](https://github.com/OpenVoiceOS/ovos-bus-client/pull/57) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a14](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a14) (2023-10-16) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a13...V0.0.6a14) - -**Implemented enhancements:** - -- add simple\_cli entrypoint [\#56](https://github.com/OpenVoiceOS/ovos-bus-client/pull/56) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a13](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a13) (2023-10-09) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a12...V0.0.6a13) - -**Implemented enhancements:** - -- feat: extend wait\_for\_response to accept list [\#52](https://github.com/OpenVoiceOS/ovos-bus-client/pull/52) ([mikejgray](https://github.com/mikejgray)) - -## [V0.0.6a12](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a12) (2023-10-04) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a11...V0.0.6a12) +[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.8a1...V0.0.8a2) **Fixed bugs:** -- fix/session\_injection [\#55](https://github.com/OpenVoiceOS/ovos-bus-client/pull/55) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a11](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a11) (2023-10-03) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a10...V0.0.6a11) - -**Fixed bugs:** - -- fix/default\_session\_overwrite [\#54](https://github.com/OpenVoiceOS/ovos-bus-client/pull/54) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a10](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a10) (2023-10-03) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a9...V0.0.6a10) - -**Merged pull requests:** - -- refactor/simplify session [\#53](https://github.com/OpenVoiceOS/ovos-bus-client/pull/53) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a9](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a9) (2023-09-30) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a8...V0.0.6a9) - -**Fixed bugs:** - -- fix/session manager update [\#51](https://github.com/OpenVoiceOS/ovos-bus-client/pull/51) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a8](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a8) (2023-09-29) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a7...V0.0.6a8) - -**Implemented enhancements:** - -- feat/session\_per\_bus\_connection [\#50](https://github.com/OpenVoiceOS/ovos-bus-client/pull/50) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a7](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a7) (2023-09-22) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a6...V0.0.6a7) - -**Implemented enhancements:** - -- feat/pipeline\_session [\#49](https://github.com/OpenVoiceOS/ovos-bus-client/pull/49) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a6](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a6) (2023-09-14) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a5...V0.0.6a6) - -**Fixed bugs:** - -- hotfix/site\_id\_seriallization [\#48](https://github.com/OpenVoiceOS/ovos-bus-client/pull/48) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a5](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a5) (2023-09-12) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a4...V0.0.6a5) - -**Implemented enhancements:** - -- add site\_id [\#47](https://github.com/OpenVoiceOS/ovos-bus-client/pull/47) ([JarbasAl](https://github.com/JarbasAl)) - -## [V0.0.6a4](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a4) (2023-08-29) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a3...V0.0.6a4) - -**Merged pull requests:** - -- Update EventScheduler init for backwards-compat. [\#46](https://github.com/OpenVoiceOS/ovos-bus-client/pull/46) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [V0.0.6a3](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a3) (2023-08-07) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a2...V0.0.6a3) - -**Merged pull requests:** - -- Remove duplicated classes from `ovos_utils` [\#44](https://github.com/OpenVoiceOS/ovos-bus-client/pull/44) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [V0.0.6a2](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a2) (2023-08-04) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.6a1...V0.0.6a2) - -**Merged pull requests:** - -- Init fix, logging updates, and unit tests [\#45](https://github.com/OpenVoiceOS/ovos-bus-client/pull/45) ([NeonDaniel](https://github.com/NeonDaniel)) - -## [V0.0.6a1](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.6a1) (2023-08-01) - -[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.5...V0.0.6a1) +- fix/get\_message\_lang [\#71](https://github.com/OpenVoiceOS/ovos-bus-client/pull/71) ([JarbasAl](https://github.com/JarbasAl)) -**Merged pull requests:** +## [V0.0.8a1](https://github.com/OpenVoiceOS/ovos-bus-client/tree/V0.0.8a1) (2023-12-29) -- debug logs on message emit failure [\#43](https://github.com/OpenVoiceOS/ovos-bus-client/pull/43) ([JarbasAl](https://github.com/JarbasAl)) +[Full Changelog](https://github.com/OpenVoiceOS/ovos-bus-client/compare/V0.0.7...V0.0.8a1) diff --git a/ovos_bus_client/util/__init__.py b/ovos_bus_client/util/__init__.py index 077babc..9f67b26 100644 --- a/ovos_bus_client/util/__init__.py +++ b/ovos_bus_client/util/__init__.py @@ -38,9 +38,11 @@ def get_message_lang(message=None): return None # old style lang param lang = message.data.get("lang") or message.context.get("lang") + if lang: + return lang # new style session lang - if not lang and "session_id" in message.context or "session" in message.context: + if "session_id" in message.context or "session" in message.context: sess = SessionManager.get(message) return sess.lang diff --git a/ovos_bus_client/version.py b/ovos_bus_client/version.py index bd53d5f..e157dbf 100644 --- a/ovos_bus_client/version.py +++ b/ovos_bus_client/version.py @@ -1,6 +1,6 @@ # START_VERSION_BLOCK VERSION_MAJOR = 0 VERSION_MINOR = 0 -VERSION_BUILD = 7 +VERSION_BUILD = 8 VERSION_ALPHA = 0 # END_VERSION_BLOCK diff --git a/requirements.txt b/requirements.txt index deca34a..17c6bbc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ovos-config >= 0.0.12, < 0.1.0 -ovos-utils >= 0.0.37, < 0.1.0 +ovos-config >= 0.0.12, < 0.2.0 +ovos-utils >= 0.0.37, < 0.2.0 websocket-client>=0.54.0 pyee>=8.1.0, < 9.0.0 diff --git a/test/unittests/test_message.py b/test/unittests/test_message.py index 33d51be..a3b285a 100644 --- a/test/unittests/test_message.py +++ b/test/unittests/test_message.py @@ -4,6 +4,8 @@ from unittest import TestCase import json from ovos_bus_client import Message +from ovos_bus_client.util import get_message_lang +from ovos_config.locale import setup_locale from ovos_bus_client.message import dig_for_message from ovos_bus_client.session import Session, SessionManager @@ -155,6 +157,23 @@ def test_class_patching(self): self.assertIsInstance(m2, Message) +class TestLanguageExtraction(TestCase): + def test_no_lang_in_message(self): + """No lang in message should result in lang from active locale.""" + setup_locale("it-it") + msg = Message('test msg', data={}) + self.assertEqual(get_message_lang(msg), 'it-it') + setup_locale("en-us") + self.assertEqual(get_message_lang(msg), 'en-us') + + def test_lang_exists(self): + """Message has a lang code in data, it should be used.""" + msg = Message('test msg', data={'lang': 'de-de'}) + self.assertEqual(get_message_lang(msg), 'de-de') + msg = Message('test msg', data={'lang': 'sv-se'}) + self.assertEqual(get_message_lang(msg), 'sv-se') + + class TestCollectionMessage(unittest.TestCase): # TODO pass