/**
 * GENE Motion — Scroll Hero: block registration.
 */
import { registerBlockType } from '@wordpress/blocks';
import { setLocaleData } from '@wordpress/i18n';

import metadata from './block.json';
import Edit from './edit';
import save from './save';
import localeJa from '../locale-ja';

import './style.scss';
import './editor.scss';

// Editor UI in Japanese when the WordPress site's locale is Japanese. PHP
// injects the site locale into window.geneMotionConfig (see
// gene_blocks_editor_config()); this must run before Edit ever renders, so it
// sits here at the top of the editor bundle's own entry, ahead of registration.
const siteLocale =
	( typeof window !== 'undefined' && window.geneMotionConfig && window.geneMotionConfig.locale ) || '';
if ( String( siteLocale ).slice( 0, 2 ) === 'ja' ) {
	setLocaleData( localeJa, 'gene-section-builder' );
}

registerBlockType( metadata.name, {
	edit: Edit,
	save,
} );
