const defaultSystem = {
  language: "pt-pt",
  company: {},
  translations: {
    "en-us": {
      welcome: "Welcome to the stock management system",
      login: "Login",
      logout: "Logout",
      settings: "Settings",
      language: "Language",
      email: "Email",
      password: "Password",
      submit: "Submit",
      cancel: "Cancel",
      error: {
        invalid_credentials: "Invalid credentials. Please try again.",
        server_error: "Server error. Please try again later.",
      },
    },

    "pt-pt": {
      welcome: "Bem-vindo ao sistema de gestão de stock",
      login: "Entrar",
      logout: "Sair",
      settings: "Configurações",
      language: "Língua",
      email: "Email",
      password: "Senha",
      submit: "Enviar",
      cancel: "Cancelar",
      error: {
        invalid_credentials: "Credenciais inválidas. Tente novamente.",
        server_error: "Erro no servidor. Por favor, tente mais tarde.",
      },
    },
  },
};

function t(key, lang = defaultSystem.language) {
  const keys = key.split(".");
  return keys.reduce((obj, k) => (obj && obj[k] !== undefined ? obj[k] : null), defaultSystem.translations[lang]);
}