afegit suport multiidioma
afegida traducció al valencià
This commit is contained in:
26
source/core/locale/locale.hpp
Normal file
26
source/core/locale/locale.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
// Clase Locale: gestiona las traducciones del juego (singleton)
|
||||
// Las traducciones se cargan desde un fichero YAML en el inicio.
|
||||
// No se permite cambio de idioma en caliente.
|
||||
class Locale {
|
||||
public:
|
||||
static void init(const std::string& file_path); // Crea e inicializa el singleton
|
||||
static void destroy(); // Destruye el singleton
|
||||
static auto get() -> Locale*; // Devuelve el singleton
|
||||
|
||||
// Devuelve la traducción de la clave dada.
|
||||
// Si la clave no existe, devuelve la propia clave como fallback.
|
||||
[[nodiscard]] auto get(const std::string& key) const -> std::string;
|
||||
|
||||
private:
|
||||
Locale() = default;
|
||||
void loadFromFile(const std::string& file_path);
|
||||
void flatten(const void* node_ptr, const std::string& prefix); // Aplana nodos YAML anidados
|
||||
|
||||
static Locale* locale_;
|
||||
std::unordered_map<std::string, std::string> strings_;
|
||||
};
|
||||
Reference in New Issue
Block a user