GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - polylang/polylang-react-library: A collection of React components and utilities for Polylang-related projects, ideal for Gutenberg integration.

BranchesTags
Open more actions menu

Latest commit

 

History

58 Commits
58 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.npmpackagejsonlintrc.json
.npmpackagejsonlintrc.json
 
 
.nvmrc
.nvmrc
 
 
.typos.toml
.typos.toml
 
 
README.md
README.md
 
 
babel.config.json
babel.config.json
 
 
eslint.config.cjs
eslint.config.cjs
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

Polylang React Library

A unified package of icons, hooks, and utilities for Polylang projects, optimized for WordPress Gutenberg integration.

📦 What's Included

  • 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

🚀 Installation

npm install @wpsyntex/polylang-react-library

The published package ships pre-transpiled JavaScript in build/ (JSX compiled with Babel and @wordpress/babel-preset-default). WordPress and React packages remain peer dependencies so consumers can externalize them (e.g. via webpack externals to wp.* / React).

From GitHub (development)

npm install github:polylang/polylang-react-library

When installing from GitHub, the prepare script builds src/ to build/. That requires a local clone with devDependencies installed (npm install in this repository); prefer the npm package for consumers.

💻 Usage

Icons

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>
	);
}

Middlewares

import { editorsRequestsFilter, filterPathMiddleware } from '@wpsyntex/polylang-react-library';

// Apply language filtering to editor requests
editorsRequestsFilter( ( options ) => {
	return {
		...options,
		data: {
			...options.data,
			lang: 'en',
		},
	};
} );

Hooks

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>;
}

🛠️ Development

Setup

npm install
npm run build         # Build src/ to build/

Linting

npm run lint          # Check code
npm run lint:fix      # Fix automatically

📋 Available Exports

  • duplication - Copy/duplicate icon
  • pencil - Edit icon
  • plus - Add/create icon
  • synchronization - Sync icon
  • translation - Translation icon
  • trash - Delete icon
  • star - Favorite/default icon
  • SubmenuIcon - Submenu navigation icon

Middlewares

  • editorsRequestsFilter - Filter WordPress editor requests
  • filterPathMiddleware - Filter requests by path matching

Hooks

  • useCuratedLanguages - Curate languages list with current language first
  • useCurrentLanguage - Get the current language from the editor
  • useLanguagesList - Fetch the list of available languages

📄 Requirements

  • Node.js >= 22.0.0
  • npm >= 10.0.0

Peer Dependencies

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.0
  • lodash >= 4.17.0
  • react >= 17.0.0

📄 License

GPL-3.0+

About

A collection of React components and utilities for Polylang-related projects, ideal for Gutenberg integration.

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.