META-INF.resources.js.ChangeDefaultLanguage.es.js Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
import ClayButton from '@clayui/button';
import ClayDropDown from '@clayui/drop-down';
import ClayIcon from '@clayui/icon';
import ClayLabel from '@clayui/label';
import ClayLayout from '@clayui/layout';
import PropTypes from 'prop-types';
import React, {useCallback, useState} from 'react';
function ChangeDefaultLanguage(props) {
const [active, setActive] = useState(false);
const [selectedDefaultLanguage, setSelectedDefaultLanguage] = useState(
props.defaultLanguage
);
const onItemClick = useCallback((event, language) => {
setSelectedDefaultLanguage(language);
setActive(false);
Liferay.fire('inputLocalized:defaultLocaleChanged', {
item: event.currentTarget,
});
}, []);
return (
{`${Liferay.Language.get(
'web-content-default-language'
)}: `}
{props.strings[selectedDefaultLanguage]}
{Liferay.Language.get('change')}
}
>
{props.languages.map((item) => (
onItemClick(event, item.label)}
title={item.label}
>
{item.label}
{item.label === selectedDefaultLanguage && (
{Liferay.Language.get('default')}
)}
))}
);
}
ChangeDefaultLanguage.propTypes = {
languages: PropTypes.arrayOf(
PropTypes.shape({
icon: PropTypes.string,
label: PropTypes.string,
})
).isRequired,
strings: PropTypes.object.isRequired,
};
export default ChangeDefaultLanguage;