<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="language" type="languageDeclarationType">
        <xs:unique name="vendorCode">
            <xs:selector xpath="use"/>
            <xs:field xpath="@vendor"/>
            <xs:field xpath="@package"/>
        </xs:unique>
    </xs:element>

    <xs:complexType name="languageDeclarationType">
        <xs:annotation>
            <xs:documentation>Magento language package declaration</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element minOccurs="1" maxOccurs="1" name="code" type="codeType"/>
            <xs:element minOccurs="1" maxOccurs="1" name="vendor" type="vendorType"/>
            <xs:element minOccurs="1" maxOccurs="1" name="package" type="packageType"/>
            <xs:element minOccurs="0" maxOccurs="1" name="sort_order" type="xs:integer"/>
            <xs:element minOccurs="0" maxOccurs="unbounded" name="use" type="useType"/>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="codeType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-z]{2}_([a-zA-Z]{4}_)?[A-Z]{2}"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="vendorType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z\-_]+"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="packageType">
        <xs:restriction base="xs:string">
            <xs:pattern value="[a-zA-Z\-_]+"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="useType">
        <xs:attribute use="required" name="vendor" type="vendorType"/>
        <xs:attribute use="required" name="package" type="packageType"/>
    </xs:complexType>
</xs:schema>
