How to use the i18n/useTranslation.useTranslation function in i18n

To help you get started, we’ve selected a few i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3scale / porta / portafly / src / components / data-list / BulkSelectorWidget.tsx View on Github external
const BulkSelectorWidget: React.FunctionComponent = ({
  filteredRows
}) => {
  const { t } = useTranslation('shared')
  const { selectPage, selectAll, selectedRows } = useDataListTable()
  const { startIdx, endIdx } = useDataListPagination()

  const [isOpen, setIsOpen] = useState(false)

  const selectedCount = selectedRows.length
  const visibleRows = filteredRows.slice(startIdx, endIdx)
  const pageCount = visibleRows.length
  const allCount = filteredRows.length

  const onSelect = () => setIsOpen((current) => !current)

  // FIXME: Setting isChecked null creates an error in the console for uncontrolled React prop
  // eslint-disable-next-line no-nested-ternary
  const isChecked = (selectedCount === 0) ? false
    : (selectedCount === allCount) ? true
github 3scale / porta / portafly / src / components / data-list / BulkActionsWidget.tsx View on Github external
const BulkActionsWidget: React.FunctionComponent = ({
  actions
}) => {
  const { t } = useTranslation('shared')
  const { selectedRows } = useDataListTable()
  const { setModal } = useDataListBulkActions()
  const isDisabled = selectedRows.length === 0

  const [isOpen, setIsOpen] = useState(false)

  const toggle = (
    
      {t('bulk_actions.title')}
    
  )

  const warning = [
    // FIXME: add styles to look like in mockup
github 3scale / porta / portafly / src / components / shared / data-list / modals / DataListModal.tsx View on Github external
const DataListModal: React.FunctionComponent = ({
  children,
  items,
  title,
  submitButton,
  to,
  errorMsg,
  shouldWarnClose
}) => {
  const { t } = useTranslation('shared')
  const { closeModal } = useDataListBulkActions()

  const [isListCollapsed, setIsListCollapsed] = useState(items.length > 5)

  const onClose = () => {
    // eslint-disable-next-line no-alert
    if (!shouldWarnClose || window.confirm(t('modals.close_confirmation'))) {
      closeModal()
    }
  }

  const textListItems = useMemo(
    () => items.map((a) => {a}),
    [items]
  )
github 3scale / porta / portafly / src / components / pages / accounts / ActionButtonApprove.tsx View on Github external
const ActionButtonApprove: React.FunctionComponent = ({ id }) => {
  const { t } = useTranslation('accountsIndex')
  const { addAlert } = useAlertsContext()

  const [isDisabled, setIsDisabled] = useState(false)

  const onClick = () => {
    setIsDisabled(true)
    approveAccount(id)
      .then((res) => {
        console.log(res)
        addAlert({ id, title: 'Success', variant: 'success' })
      })
      .catch((err) => {
        console.log(err)
        addAlert({ id, title: 'Success', variant: 'danger' })
      })
      .finally(() => setIsDisabled(false))
github 3scale / porta / portafly / src / components / pages / audience / accounts / listing / DeveloperAccountsTable.tsx View on Github external
const DeveloperAccountsTable: React.FunctionComponent = ({ accounts }) => {
  const { t } = useTranslation('audienceAccountsListing')

  if (accounts.length === 0) {
    return 
  }

  const COLUMNS = [
    t('accounts_table.group_header'),
    t('accounts_table.admin_header'),
    t('accounts_table.signup_header'),
    t('accounts_table.applications_header'),
    t('accounts_table.state_header')
  ]

  const rows: string[][] = accounts.map((a) => [
    a.org_name,
    a.admin_name,
github 3scale / porta / portafly / src / components / pages / accounts / AccountsTable.tsx View on Github external
const AccountsTable: React.FunctionComponent = () => {
  const { t } = useTranslation('accountsIndex')
  const {
    columns,
    rows,
    sortBy,
    setSortBy
  } = useDataListTable()

  if (rows.length === 0) {
    return 
  }

  const { startIdx, endIdx, resetPagination } = useDataListPagination()
  const { filters } = useDataListFilters()

  const options = [
    { name: 'approved', humanName: t('actions_filter_options.by_state_options.approved') },
github 3scale / porta / portafly / src / components / pages / product / CreateProductPage.tsx View on Github external
const CreateProductPage = () => {
  const { t } = useTranslation('product')
  useDocumentTitle(t('create.pagetitle'))
  const { goBack } = useHistory()
  const { addAlert } = useAlertsContext()

  const [name, setName] = useState('')
  const [systemName, setSystemName] = useState('')
  const [description, setDescription] = useState('')
  const [validations, setValidations] = useState({
    name: { validation: 'default' },
    system_name: { validation: 'default' },
    description: { validation: 'default' }
  })

  const {
    isPending, error, run, data
  } = useAsync({ deferFn: createProduct })
github 3scale / porta / portafly / src / components / Root.tsx View on Github external
const Root: React.FunctionComponent = ({ children }) => {
  const { t } = useTranslation('shared')
  const { authToken } = useAuth()
  const Logo = 

  const navItems = [
    {
      title: t('navigation_items.overview'),
      to: '/',
      exact: true
    },
    {
      title: t('navigation_items.analytics'),
      to: '/analytics',
      items: [
        { to: '/analytics/usage', title: t('navigation_items.analytics_usage') }
      ]
    },
github 3scale / porta / portafly / src / components / util / AlertsContext.tsx View on Github external
const AlertsProvider: React.FunctionComponent = ({ children }) => {
  const { t } = useTranslation('shared')

  type AlertsState = Array
  const [alerts, setAlerts] = React.useState([])

  const removeAlert = (id: string) => (
    setAlerts((prevAlerts) => prevAlerts.filter((a) => a.id !== id))
  )

  const addAlert = (alert: IAlert) => {
    const timeout = setTimeout(() => removeAlert(alert.id), TIMEOUT)
    setAlerts((prevAlerts) => [...prevAlerts, { ...alert, timeout }])
  }

  const CloseButton = ({ id, timeout }: { id: string, timeout: NodeJS.Timeout }) => (
github 3scale / porta / portafly / src / components / AppHeaderTools.tsx View on Github external
const AppHeaderTools: React.FunctionComponent = () => {
  const { t } = useTranslation('shared')
  const { userProfile, logout } = useAuth()

  const [isKebabDropdownOpen, setIsKebabDropdownOpen] = useState(false)
  const [isDropdownOpen, setIsDropDownOpen] = useState(false)

  const kebabDropdownItems = [
    
      
      {' Settings'}
    ,
    
      
      {' Help'}
    
  ]