Language manager approach with design patterns

Hello fellow programmers!

In my current project, i work on a small plugin system, and everything works perfectly fine, but i can't find the right approach to my language manager.

What i want: An object that handles all the language related workload.

I thought about using the observer pattern because the application and the plugins shall be able to change the language of the application text at runtime.
And i also thought about using the singleton pattern to make the object easily accessable for all the plugins. But when i started reading more about singletons, it appears to me that it may be a bad choice.

There are a lot of opinions about Singletons and that giving the object via function parameters is better by design.

How would you approach that "problem" and how bad excactly are singletons?
Thanks in advance!
How would you approach that "problem" and how bad excactly are singletons?
The problem with the singleton in your case is that they are local to the program/plugin. So other plugins will not see them. They are also problematic regarding threads and modifications in general.

I thought about using the observer pattern
Yes, that could be a way. You may pass that text/language object as a shared_ptr to the functions/classes. For the notifications boost provides a signal/slot mechanism:

https://www.boost.org/doc/libs/1_76_0/doc/html/signals2.html

which makes it relatively simple to implement the observer pattern.
Thanks, that helped me alot! i have read quite a bit from the link you sent, but i guess boost is not part of the standart library? it doesnt look hard to implement my own lightweight signal/slot mechanism.

I try to avoid non standart libaries as much as possible because almost every project i have is for the purpose of education.

Anyway, i think i found a solution to my "problem" now, thanks!
Topic archived. No new replies allowed.