A unified package of icons, hooks, and utilities for Polylang projects, optimized for WordPress Gutenberg integration.
- SVG Icons - Complete icon library for Polylang projects
- React Hooks - Custom hooks for language management and state handling
- API Middlewares - WordPress REST API filtering utilities
The package is not yet published to npm.
npm install github:polylang/polylang-react-libraryThe package automatically builds during installation via the prepare script. The source code in src/ is transpiled to build/ using Babel with WordPress presets.
import {
duplication,
pencil,
plus,
synchronization,
translation,
trash,
star,
SubmenuIcon,
} from '@wpsyntex/polylang-react-library';
function MyToolbar() {
return (
<div>
<button>{ duplication } Duplicate</button>
<button>{ pencil } Edit</button>
<button>{ trash } Delete</button>
</div>
);
}import { editorsRequestsFilter, filterPathMiddleware } from '@wpsyntex/polylang-react-library';
// Apply language filtering to editor requests
editorsRequestsFilter( ( options ) => {
return {
...options,
data: {
...options.data,
lang: 'en',
},
};
} );import {
useCuratedLanguages,
useCurrentLanguage,
useLanguagesList,
} from '@wpsyntex/polylang-react-library';
function LanguageSelector() {
// Fetch all available languages
const languages = useLanguagesList();
// Get the current language from the editor
const currentLanguage = useCurrentLanguage( languages );
// Curate languages with current language first
const curatedLanguages = useCuratedLanguages(
languages,
currentLanguage,
false
);
return <div>{ currentLanguage?.name }</div>;
}npm install
npm run build # Build src/ to build/npm run lint # Check code
npm run lint:fix # Fix automaticallyduplication- Copy/duplicate iconpencil- Edit iconplus- Add/create iconsynchronization- Sync icontranslation- Translation icontrash- Delete iconstar- Favorite/default iconSubmenuIcon- Submenu navigation icon
editorsRequestsFilter- Filter WordPress editor requestsfilterPathMiddleware- Filter requests by path matching
useCuratedLanguages- Curate languages list with current language firstuseCurrentLanguage- Get the current language from the editoruseLanguagesList- Fetch the list of available languages
- Node.js >= 20.0.0
- npm >= 10.0.0
This package requires the following peer dependencies (provided by consuming projects):
@wordpress/api-fetch>= 7.0.0@wordpress/data>= 10.0.0@wordpress/editor>= 14.0.0@wordpress/element>= 6.0.0@wordpress/primitives>= 4.0.0lodash>= 4.17.0react>= 17.0.0
GPL-3.0+