# ===============================================
# LOCALIZATION
# ===============================================

extend type Query {
  localization: LocalizationQuery
}

extend type Mutation {
  localization: LocalizationMutation
}

# -----------------------------------------------
# QUERIES
# -----------------------------------------------

type LocalizationQuery {
  locales: [LocalizationLocale]
  config: LocalizationConfig
  translations(locale: String!, namespace: String!): [Translation]
}

# -----------------------------------------------
# MUTATIONS
# -----------------------------------------------

type LocalizationMutation {
  downloadLocale(
    locale: String!
  ): DefaultResponse @auth(requires: ["manage:system"])

  updateLocale(
    locale: String!
    autoUpdate: Boolean!
    namespacing: Boolean!
    namespaces: [String]!
  ): DefaultResponse @auth(requires: ["manage:system"])
}

# -----------------------------------------------
# TYPES
# -----------------------------------------------

type LocalizationLocale {
  code: String!
  createdAt: Date!
  installDate: Date
  isInstalled: Boolean!
  isRTL: Boolean!
  name: String!
  nativeName: String!
  updatedAt: Date!
}

type LocalizationConfig {
  locale: String!
  autoUpdate: Boolean!
  namespacing: Boolean!
  namespaces: [String]!
}

type Translation {
  key: String!
  value: String!
}
