% \iffalse meta-comment
%
% This program can be distributed and/or modified under the terms
% of the LaTeX Project Public License either version 1.3c of this
% license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
%<*batch>
%<*gobble>
\ifx\jobname\relax\let\documentclass\undefined\fi
\ifx\documentclass\undefined
\csname fi\endcsname
%</gobble>
\input docstrip.tex
\keepsilent
\let\MetaPrefix\relax
\preamble
This is a generated file part of the babel-breton bundle
to be used with the Babel system.
-------------------------------------------------------------

It may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version.
The latest version of this license is in
  http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of LaTeX
version 2003/12/01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainer of this work is Jacques André.

Please report errors to: <jacques (dot) andre 35 (at) gmail (dot) com>

\endpreamble
\postamble
\endpostamble
\let\MetaPrefix\DoubleperCent
\askforoverwritefalse
\generate{\file{breton.ldf}{\from{breton.dtx}{ldf}}
         }
\endbatchfile
%</batch>
%<*gobble>
\fi
\expandafter\ifx\csname @currname\endcsname\empty
\csname fi\endcsname
%</gobble>
%
%<*dtx>
\ProvidesFile{breton.dtx}
%</dtx>
%<*ldf>
%%
%% Babel package for LaTeX version 2e
%% Copyright © 2026 -
%%           by Jacques André <jacques (dot) andre 35 (at) gmail (dot) com>
%%
%% Copyright  © 1989 - 2026
%%           by Johannes Braams, TeXniek
%%           by Javier Bezos
%%
%% Breton Language Definition File
%% Copyright  © 1994 - 2005
%%           by Christian Rolland
%%              Universite de Bretagne occidentale
%%              Departement d'informatique
%%              6, avenue Le Gorgeu
%%              BP 452
%%              29275 Brest Cedex -- FRANCE
%%              Christian.Rolland at univ-brest.fr (Internet)
%%
%%  This file is part of the babel system, it provides the source
%%  code for the Breton language definition file.
%%
\NeedsTeXFormat{LaTeX2e}[2025-06-01]
\ProvidesFile{breton.ldf}
%</ldf>
             [2026-05-17 v2.0.1 Breton support from the babel system]
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}[2025-06-01]
%\DocumentMetadata{pdfstandard={A-4,UA-2}, tagging=on, lang=en-GB}
\documentclass[a4paper]{ltxdoc}
\usepackage[left=38mm,right=38mm,top=30mm,bottom=50mm]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage[no-math]{fontspec}
\usepackage{realscripts}
\usepackage{setspace}
\setstretch{1.15}
\setmainfont{SourceSans3}[% changed to SourceSans3 = New Adobe name for former SourceSansPro
    Scale          = 1.13 ,
    Extension      = .otf ,
    UprightFont    = *-Regular ,
    ItalicFont     = *-RegularIt ,
    BoldFont       = *-Bold ,
    BoldItalicFont = *-BoldIt ]
\setmonofont{JuliaMono}[%
    Scale = MatchLowercase,   FakeStretch = .9 ,
    HyphenChar=None,
    Extension = .ttf,
    UprightFont = *-Regular,
    ItalicFont = *-RegularItalic,
    BoldFont = *-Bold,
    BoldItalicFont = *-BoldItalic,
  ]
\usepackage[british]{babel}
%
\def\PrintMacroName#1{%
  \strut\MacroFont\color{Sepia}\normalsize\string#1}
\def\ColorArg{\color{Sepia}}
\usepackage[verbose=silent]{microtype}
\usepackage{array,url}
\usepackage[numbered]{hypdoc}
\hypersetup{colorlinks,urlcolor=Blue,linkcolor=Blue}
\newcommand*{\hlabel}[1]{\phantomsection\label{#1}}
\newcommand*\file[1]{\texttt{#1}}
\newcommand*\cls[1]{\texttt{#1}}
\newcommand*\pkg[1]{\texttt{#1}}
\newcommand*\opt[1]{\texttt{#1}}
\newcommand*\env[1]{\texttt{#1}}
\newcommand*\exe[1]{\texttt{#1}}
\renewcommand\meta[1]{\textit{<#1>}}  % no math mode (see doc.sty)
\let\Module\meta                      % no math mode (see doc.sty)
\NewCommandCopy{\up}{\textsuperscript}
\hyphenation{Lua-TeX Lua-LaTeX Xe-LaTeX}
\lefthyphenmin=2 \righthyphenmin=3
\setlength{\parindent}{0pt}
%\RecordChanges
%\AtEndDocument{%
%   \clearpage
%   \section{Change History}%
%   \GlossaryPrologue{}%
%   List of changes.
%   \PrintChanges
%}
\begin{document}
\GetFileInfo{breton.ldf}
%
\begin{center}
  \textbf{\Large A Babel language definition file for Breton}\\[2mm]^^A\]
  \textbf{\large breton.dtx \fileversion, \filedate}\\[3mm]^^A\]
  Jacques André\\
  \texttt{Jacques.Andre35@gmail.com}
\end{center}
\vspace{2\baselineskip}
\thispagestyle{empty}
\tableofcontents
\clearpage
\DocInput{breton.dtx}
\end{document}
%</driver>
%<*gobble>
\fi
%</gobble>
%
% \fi
%
%  \section{The Breton language}
%
% \changes{breton-1.0e}{1996/10/10}{Replaced \cs{undefined} with
%    \cs{@undefined} and \cs{empty} with \cs{@empty} for consistency
%    with \LaTeX, moved the definition of \cs{atcatcode} right to the
%    beginning.}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate.} defines all the language-specific macros for the Breton
%    language.
%
%    There are not really typographic rules for the Breton
%    language. It is a regional language (it's one of the celtic
%    languages) which is spoken in Brittany (West of France). So we
%    have a synthesis between Breton typographic rules and French
%    typographic rules. The characters \texttt{:}, \texttt{;},
%    \texttt{!} and \texttt{?} get a whitespace automatically before
%    them as in French.
%
%    This version (\fileversion, \filedate) supports new encoding
%    for ``the" character C'H, and uses new caption names.
%    Furthermore, compatibilities between pdfTeX, lualatex and xelatex	have been
%    upgraded with the deep help of Daniel Flipo.
%
%  \subsection{Basic interface}
%  \label{ssec-basic}
%
%    The \pkg{breton} language for Babel works for lualatex, xelatex and
%    pdflatex.
%
%    \textbf{Requirements:}
%    \begin{enumerate}
%      \item user’s documents \emph{must} be coded in UTF-8, also for
%        pdflatex.
%      \item pdflatex users \emph{must} use fonts in T1 encoding,
%        this means adding a\\ |\usepackage[T1]{fontenc}| command in the
%        preamble.
%    \end{enumerate}
%
%  \subsubsection{Punctuation}
%  \label{sssec-punctuation}
%
%    High punctuation (\texttt{:;!?}) in Breton requires, as in French,
%    some space to be added in front of it. The automatic insertion of
%    these spaces is handled in two different ways: for the pdftex and
%    xetex engines, active characters are used, while luatex provides
%    a safer alternative.
%
%    The default behaviour of \file{breton.ldf} is to add a thin
%    (nobreak, no stretch) space in front of \texttt{;!?} and an
%    inter-word (stretchable, nobreak) space in front of the colon.
%
%    These spaces are customisable through two commands
%    |\BRSetThinSpace| and |\BRSetColonSpace|. They both require three
%    mandatory arguments which are decimal numbers specifying
%    \textit{width}, \textit{stretch} and \textit{shrink} relative to
%    the relevant \textit{fontdimens}. Examples:\\
%    |\BRSetColonSpace{1}{1}{1}| provides exactly an inter-word space.\\
%    |\BRSetThinSpace{0.5}{0}{0}| provides a thin space (half width of
%    the inter-word space, no elasticity).
%
%    The automatic insertion of spaces in front of high punctuation is
%    disabled for Typewriter fonts and hence in verbatim mode.
%
%    A command |\NoBRspacing| is provided to disable the automatic
%    insertion of spaces in front of high punctuation if needed.
%    It is meant to be used inside a group.  For instance with
%    pdflatex or xelatex, coding |{\NoBRspacing (!)}| or
%    |{\NoBRspacing ??}| to avoid spurious spaces is
%    recommended. Fortunately lualatex handles these cases flawlessly.
%
%  \subsubsection{Caption names}
%  \label{sssec-captions-name}
%
%    The former  list of caption names  (such as |\chaptername|)
%    has been revisited, mainly according to recommendations of OPLB.
%    Furthermore,  |\partname|  is now numbered with ordinals
%    (e.g. \emph{Lodenn gentañ, Eil lodenn, ...}) instead of roman numbers
%    (e.g. \emph{Lodenn I, Lodenn II, ...}).
%
%    To the regular |\today| is added a new command |\deiziad{year}{month}{day}|
%    that prints the corresponding date in breton.
%
% \StopEventually{}
%
%  \clearpage
%  \newgeometry{left=50mm,right=23mm}
%
%  \section{The code}
%
%  \subsection{Initial setup}
%
% \iffalse
%<*ldf>
% \fi
%
%    \begin{macrocode}
\ProvidesLanguage{breton}
%    \end{macrocode}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once (even if both options \opt{breton} and
%    \opt{acadian} are used in the same document), checking the
%    category code of the \texttt{@} sign, etc.
%
%    \begin{macrocode}
\LdfInit{breton}{captionsbreton}
%    \end{macrocode}
%
%    Quit if Babel’s version is less than 24.14.
%    \begin{macrocode}
\let\bbl@tempa\relax
\ifdefined\babeltags
\else
   \let\bbl@tempa\endinput
   \PackageError{breton.ldf}
         {babel-breton requires babel v.24.14.\MessageBreak
          Aborting here}
         {Please upgrade Babel!}
\fi
\bbl@tempa
%    \end{macrocode}
%
%    Make sure that |\l@breton| is defined (fallback is language 0
%    US-english).
%    \begin{macrocode}
\ifdefined\l@breton
\else
  \@nopatterns{breton}
  \adddialect\l@breton0
\fi
%    \end{macrocode}
%
%    Breton uses the standard values of |\lefthyphenmin| (2)
%    and |\righthyphenmin| (3); let’s provide their values though,
%    as required by Babel.
%
%    \begin{macrocode}
\providehyphenmins{breton}{\tw@\thr@@}
%    \end{macrocode}
%
% \begin{macro}{\extrasbreton}
% \begin{macro}{\noextrasbreton}
%    The macro |\extrasbreton| will perform all the extra
%    definitions needed for the Breton language.
%    The macro |\noextrasbreton| is used to cancel the actions of
%    |\extrasbreton|.
%
%    In Breton, the quote character (U+27 or U+2019 or even 02BC) is
%    a  letter in expressions like |C'hwevrer| (February).
%    Breton hyphenation patterns need to provide entries for this kind
%    of words.  This means that its |\lccode| has to be non null in
%    Breton for proper hyphenation of those expressions, and has to be
%    reset to null when exiting Breton.
%
%    \begin{macrocode}
\def\extrasbreton{%
     \babel@savevariable{\lccode"27}%
     \lccode"27="27
     \ifnum\bbl@engine > \z@
       \babel@savevariable{\lccode"2019}%
       \lccode"2019="2019
     \fi
}
%    \end{macrocode}
%
%    One more thing |\extrasbreton| needs to do is to make sure that
%    ``Frenchspacing’’ is in effect.  |\noextrasfrench| will switch
%    ``Frenchspacing’’ off again if necessary.
%
%    A new conditional is used to switch off, if needed, automatic
%    insertion of spaces in front of \texttt{;} \texttt{!}  \texttt{?},
%    \texttt{:}, \texttt{«} and \texttt{»}.
%    \begin{macrocode}
\newif\ifBR@spacing
\addto\extrasbreton{\bbl@frenchspacing \BR@spacingtrue}
\addto\noextrasbreton{\bbl@nonfrenchspacing \BR@spacingfalse}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%  \subsection{Breton apostrophe U+02BC}
%  \label{ssec-apost}
%
%    Strangely, some organisms, such as the Public Office for Breton
%    Language (OPLB, Office Public de la Lange Bretonne,  Ofis Publik
%    ar Brezhoneg), recommends to encode the character C'H with the
%    U+02BC apostrophe. As this character is missing from most fonts,
%    it's safer to replace it with a regular apostrophe.
%
%    Substitution of char U+02BC into U+0027 (pdftex) or U+2019
%    (unicode engines).
%
%    This is for the pdftex engine; caveat: the substitution holds for
%    all languages, not just Breton.
%    \begin{macrocode}
\ifcase\bbl@engine
  \DeclareUnicodeCharacter{02BC}{\char"0027}
%    \end{macrocode}
%    This is for the luatex engine.
%    \begin{macrocode}
\or
  \babelprehyphenation{breton}{ ʼ }{ string = ’ , remove }
%    \end{macrocode}
%    This is for the xetex engine.
%    \begin{macrocode}
\or
  \def\@gobblenext#1{}
  \babelcharclass{breton}{apos}{ʼ}
  \babelinterchar[apos]{breton}{default, boundary}{apos}{’\@gobblenext}
\fi
%    \end{macrocode}
%
%  \subsection{Punctuation}
%  \label{ssec-punct}
%
% \begin{macro}{\BRguillspace}
% \begin{macro}{\BRcolonspace}
% \begin{macro}{\BRthinspace}
%    Let’s define default values for punctuation spaces.
%    \begin{macrocode}
\newcommand*{\BRcolonspace}{\space}
\newcommand*{\BRthinspace}{\hskip .5\fontdimen2\font \relax}
\newcommand*{\BRguillspace}{\hskip .8\fontdimen2\font
                             plus .3\fontdimen3\font
                            minus .8\fontdimen4\font \relax}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\BRSetGuillSpace}
% \begin{macro}{\BRSetColonSpace}
% \begin{macro}{\BRSetThinSpace}
%    This command makes it easy to fine tune |\BRthinspace| and
%    |\BRcolonspace| in Breton.
%    It requires three mandatory arguments which are decimal numbers
%    specifying \textit{width}, \textit{stretch} and \textit{shrink}
%    relative to the relevant \textit{fontdimens}.\hlabel{BRsetspaces}
%    For instance |\BRSetColonSpace}{0.5}{0}{0}| defines
%    |\BRcolonspace| as a thinspace instead of a word space.
%    \begin{macrocode}
\newcommand*{\BRSetColonSpace}[3]{%
  \ifnum\bbl@engine=\@ne
    \SetTransformValue{breton}{colon.natural}{#1}%
    \SetTransformValue{breton}{colon.minus}{#2}%
    \SetTransformValue{breton}{colon.plus}{#3}%
  \else
    \renewcommand{\BRcolonspace}{%
       \hskip #1\fontdimen2\font
        plus  #2\fontdimen3\font
        minus #3\fontdimen4\font \relax}%
  \fi}
\newcommand*{\BRSetThinSpace}[3]{%
  \ifnum\bbl@engine=\@ne
    \SetTransformValue{breton}{thin.natural}{#1}%
    \SetTransformValue{breton}{thin.minus}{#2}%
    \SetTransformValue{breton}{thin.plus}{#3}%
  \else
    \renewcommand{\BRthinspace}{%
       \hskip #1\fontdimen2\font
        plus  #2\fontdimen3\font
        minus #3\fontdimen4\font \relax}%
  \fi}
\newcommand*{\BRSetGuillSpace}[3]{%
  \ifnum\bbl@engine=\@ne
    \SetTransformValue{breton}{guill.natural}{#1}%
    \SetTransformValue{breton}{guill.minus}{#2}%
    \SetTransformValue{breton}{guill.plus}{#3}%
  \else
    \renewcommand{\BRguillspace}{%
       \hskip #1\fontdimen2\font
        plus  #2\fontdimen3\font
        minus #3\fontdimen4\font \relax}%
  \fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%  \subsubsection{Punctuation for the pdftex engine}
%  \label{sssec-punct-pdftex}
%
%    |\bbl@engine| is a Babel command which expands to 0, 1 or 2
%    according to the engine used for compilation, resp. pdftex,
%    luatex, xetex.
%    For pdftex the four high punctuation characters are made active.
%    \begin{macrocode}
\ifcase\bbl@engine
  \initiate@active@char{:}
  \initiate@active@char{;}
  \initiate@active@char{!}
  \initiate@active@char{?}
%    \end{macrocode}
%    We tune the amount of space before \texttt{;}
%    \texttt{!}  \texttt{?} and \texttt{:}.
%    In horizontal mode, if a space has been typed before `;’ we
%    remove it. Then a non-breaking |\BRthinspace| is inserted.
%    \begin{macrocode}
  \declare@shorthand{breton}{;}{%
    \ifBR@spacing
      \ifhmode
        \ifdim\lastskip>1sp \unskip \fi
        \penalty\@M \BRthinspace
      \fi
    \fi
%    \end{macrocode}
%    Now we can insert a |;| character.
%    \begin{macrocode}
    \string;}
%    \end{macrocode}
%    The next three definitions are very similar.
%    \begin{macrocode}
  \declare@shorthand{breton}{!}{%
    \ifBR@spacing
      \ifhmode
        \ifdim\lastskip>1sp \unskip \fi
        \penalty\@M \BRthinspace
      \fi
    \fi
    \string!}
  \declare@shorthand{breton}{?}{%
    \ifBR@spacing
      \ifhmode
        \ifdim\lastskip>1sp \unskip \fi
        \penalty\@M \BRthinspace
      \fi
    \fi
    \string?}
  \declare@shorthand{breton}{:}{%
    \ifBR@spacing
      \ifhmode
        \ifdim\lastskip>1sp \unskip \fi
        \penalty\@M \BRcolonspace
      \fi
    \fi
    \string:}
%    \end{macrocode}
%    When the active characters appear in an environment where their
%    Breton behaviour is not wanted they should give an `expected’
%    result.  Therefore we define shorthands at system level as well.
%    \begin{macrocode}
  \declare@shorthand{system}{:}{\string:}
  \declare@shorthand{system}{!}{\string!}
  \declare@shorthand{system}{?}{\string?}
  \declare@shorthand{system}{;}{\string;}
%    \end{macrocode}
%    We specify that the Breton group of shorthands should be used when
%    switching to Breton.
%    \begin{macrocode}
  \addto\extrasbreton{\languageshorthands{breton}%
%    \end{macrocode}
%    These characters are `turned on’ once, later their definition may
%    vary.  Don’t misunderstand the following code: they keep being
%    active all along the document, even when leaving Breton.
%    \begin{macrocode}
    \bbl@activate{:}\bbl@activate{;}%
    \bbl@activate{!}\bbl@activate{?}%
  }
  \addto\noextrasbreton{%
    \bbl@deactivate{:}\bbl@deactivate{;}%
    \bbl@deactivate{!}\bbl@deactivate{?}%
  }
%    \end{macrocode}
%    French quotes (« and ») also require some additional space;
%    \begin{macrocode}
  \DeclareUnicodeCharacter{00AB}{\BR@og}
  \DeclareUnicodeCharacter{00BB}{\BR@fg}
  \newcommand*{\BR@og}{%
    \ifBR@spacing \guillemotleft\penalty\@M\BRguillspace\ignorespaces
    \else \guillemotleft
    \fi}
  \newcommand*{\BR@fg}{%
    \ifBR@spacing \ifdim\lastskip>\z@\unskip\fi \penalty\@M\BRguillspace
       \guillemotright
    \else \guillemotright
    \fi}
%    \end{macrocode}
%
%\subsubsection{Punctuation for the luatex engine}
%  \label{sssec-punct-luatex}
%
%    For the LuaTeX engine, we use the ``transforms’’ from Babel’s
%    kernel and we exclude monospaced fonts from their application.
%    \begin{macrocode}
\or
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { [^|{(}{[}{007B}!{?}] () [;!{?}] () }
    { { insert, penalty = 10000 },
      { insert, spacefactor= {high.natural|.5} {high.plus|0}
                           {high.minus|0}, data = 1 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { [^{(}{[}{007B}!{?}] () | [;!{?}] () }
    { { insert, penalty = 10000 },
      { spacefactor= {high.natural|.5} {high.plus|0}
                     {high.minus|0}, data = 2 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { [^|{(}{[}{007B} ] () : () }
    { { insert, penalty = 10000 },
      { insert, spacefactor= {colon.natural|1} {colon.plus|1}
                             {colon.minus|1}, data = 1 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { [^{(}{[}{007B} ] () |: () }
    { { insert, penalty = 10000 },
      { spacefactor= {colon.natural|1} {colon.plus|1}
                     {colon.minus|1}, data = 2 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { [^|]()»() }
    { { insert, penalty = 10000 },
      { insert, spacefactor= {guill.natural|.8} {guill.plus|.3}
                             {guill.minus|.8}, data = 1 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { [^|]()|»() }
    { { insert, penalty = 10000 },
      { spacefactor= {guill.natural|.8} {guill.plus|.3}
                     {guill.minus|.8}, data = 2 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { «[^|] }
    { {},
      { insert, penalty = 10000 },
      { insert, spacefactor= {guill.natural|.8} {guill.plus|.3}
                             {guill.minus|.8}, data = 1 },
      {} }
  \babelprehyphenation[label=breton.space, fonts=rm sf]{\CurrentOption}
    { «|[^|] }
    { {},
      { insert, penalty = 10000 },
      { spacefactor= {guill.natural|.8} {guill.plus|.3}
                     {guill.minus|.8}, data = 1 },
      {} }
%    \end{macrocode}
%
%  \subsubsection{Punctuation for the xetex engine}
%  \label{sssec-punct-xetex}
%
%    For the xetex engine, inter-character rules are defined to insert
%    spaces before the `high punctuation’ characters.
%    \begin{macrocode}
\or
  \babelcharclass{breton}{thin}{;!?}
  \babelcharclass{breton}{colon}{:}
  \babelinterchar{breton}{default,boundary}{thin}{%
    \ifBR@spacing
       \ifhmode
          \ifdim\lastskip>1sp \unskip \fi
          \penalty\@M\BRthinspace
        \fi
     \fi}%
  \babelinterchar{breton}{default,boundary}{colon}{%
    \ifBR@spacing
       \ifhmode
          \ifdim\lastskip>1sp \unskip \fi
          \penalty\@M\BRcolonspace
        \fi
     \fi}%

%    \end{macrocode}
%    This is for French quote characters:
%    \begin{macrocode}
  \babelcharclass{breton}{og}{«}
  \babelcharclass{breton}{fg}{»}
  \babelinterchar{breton}{og}{default,boundary}{%
    \ifBR@spacing \penalty\@M\BRguillspace \ignorespaces\fi}
  \babelinterchar{breton}{default,boundary}{fg}{%
    \ifBR@spacing \ifdim\lastskip>\z@ \unskip \fi
       \penalty\@M\BRguillspace\fi}
\fi
%    \end{macrocode}
%
%  \subsubsection{Punctuation switches common to all engines}
%  \label{sssec-punct-switches}
%
%    Automatic insertion of spaces in front of high punctuation is
%    canceled in for Typewriter fonts and hence in verbatim.
%    For luatex, nothing has to be done as Typewriter fonts are excluded
%    from Babel transforms.
%    For pdftex and xetex, this is done by switching the |\ifBR@spacing|
%    flag. As |\ttfamily| action may be global (when not issued inside
%    a group), |\rmfamily| and |\sffamily| need to be patched too.
%    \begin{macrocode}
\ifnum\bbl@engine=\@ne
\else
  \AddToHook{cmd/ttfamily/after}{\BR@spacingfalse}
  \AddToHook{cmd/rmfamily/after}{\BR@spacingtrue}
  \AddToHook{cmd/sffamily/after}{\BR@spacingtrue}
\fi
%    \end{macrocode}
%
% \begin{macro}{\BRNoAutoSpacing}
%    The following command disables automatic spacing for high
%    punctuation.
%    It is engine independent and is meant to be used inside a group.
%    The faked definition of |\texorpdfstring| will be overwritten
%    by \file{hyperref.sty}.
%
%    \begin{macrocode}
\providecommand\texorpdfstring[2]{#1}
\DeclareRobustCommand*{\NoBRspacing}{%
  \texorpdfstring%
    {\ifnum\bbl@engine=1
     \else
        \shorthandoff{;:!?}%
      \fi
    }%
    {}%
}
%    \end{macrocode}
% \end{macro}
%
%  \subsection{Caption names}
%  \label{ssec-captions-name}
%
%    The next step consists in defining the Breton equivalents for
%    the LaTeX caption names.
%
%    New implementation for caption names.
%    \begin{macrocode}
\StartBabelCommands*{breton}{captions}
      [unicode, fontenc=TU EU1 EU2, charset=utf8]
   \SetString{\refname}{Daveennoù}
   \SetString{\contentsname}{Taolenn ar pennadoù}
   \SetString{\listfigurename}{Listenn ar lunioù}
   \SetString{\listtablename}{Listenn an taolennoù}
   \SetString{\enclname}{Pezh stag}
   \SetStringLoop{ordinal#1}{% change 02BC to 2019
     Kentañ,Eil,Trede,Pevare,Pempvet,C’hwec’hvet,Seizhvet,Eizhvet,%
     Navvet,Dekvet,Unnekvet,Daouzekvet,Trizekvet,Pevarzekvet,Pemzekvet,%
     C’hwezekvet,Seitekvet,Triwec’hvet,Naontekvet,Ugentvet,%
     Unanvet warn-ugent,Eil warn-ugent,Trede warn-ugent,%
     Pevare warn-ugent,Pempvet warn-ugent,C’hwec’hvet warn-ugent,%
     Seizhvet warn-ugent,Eizhvet warn-ugent,Navvet warn-ugen,Tregontvet}
\StartBabelCommands*{breton}{captions}
   \SetString{\prefacename}{Rakskrid}
   \SetString{\refname}{Daveenno\`u}
   \SetString{\abstractname}{Diverradur}
   \SetString{\bibname}{Levrlennadur}
   \SetString{\chaptername}{Pennad}
   \SetString{\appendixname}{Stagadenn}
   \SetString{\contentsname}{Taolenn ar pennado\`u}
   \SetString{\listfigurename}{Listenn ar lunio\`u}
   \SetString{\listtablename}{Listenn an taolenno\`u}
   \SetString{\indexname}{Meneger}
   \SetString{\figurename}{Lun}
   \SetString{\tablename}{Taolenn}
   \SetString{\enclname}{Pez stag}
   \SetString{\ccname}{Eilad da}
   \SetString{\headtoname}{Da}
   \SetString{\pagename}{pajenn}
   \SetString{\seename}{gwelet}
   \SetString{\alsoname}{gwelet ivez}
   \SetString{\proofname}{Anatadur}
   \SetString{\glossaryname}{Geriaoueg}
%    \end{macrocode}
%    |\part{}| is printed in Breton as ``Lodenn gentañ’’ (first),
%    ``Eil lodenn’’ (second), ``Trede lodenn’’ (third) and so on.
%    \begin{macrocode}
   \SetString{\Partnameord}{Lodenn}
   \SetString{\partnameord}{lodenn}
   \SetStringLoop{ordinal#1}{%
     Kenta\~n,Eil,Trede,Pevare,Pempvet,C'hwec'hvet,Seizhvet,Eizhvet,%
     Navvet,Dekvet,Unnekvet,Daouzekvet,Trizekvet,Pevarzekvet,Pemzekvet,%
     C'hwezekvet,Seitekvet,Triwec'hvet,Naontekvet,Ugentvet,%
     Unanvet warn-ugent,Eil warn-ugent,Trede warn-ugent,%
     Pevare warn-ugent,Pempvet warn-ugent,C'hwec'hvet warn-ugent,%
     Seizhvet warn-ugent,Eizhvet warn-ugent,Navvet warn-ugen,Tregontvet}
   \SetString{\partname}{%
      \ifcase\value{part}\Partnameord
      \or \Partnameord\space genta\~n
      \else \csname ordinal\romannumeral\value{part}\endcsname
            \space \partnameord
      \fi
      \def\thepart{\unskip}}
\EndBabelCommands
%    \end{macrocode}
%
%  \subsection{Date in Breton}
% \label{sssec-date}
%
% \begin{macro}{\deiziad}
% \begin{macro}{\today}
%    \begin{macrocode}
\StartBabelCommands*{breton}{date}
  \SetStringLoop{month#1name}{%
      Genver, C'hwevrer, Meurzh, Ebrel, Mae, Mezheven,
      Gouere, Eost, Gwengolo, Here, Du, Kerzu}
  \SetString\today{\deiziad{\year}{\month}{\day}}
\EndBabelCommands
\newcommand*{\deiziad}[3]{%
  {\ifnum1=#3{\kentan}\space \else {\number#3} a viz\fi
  \csname month\romannumeral#2name\endcsname
  \ifx#1\@empty\else\space\number#1\fi}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%  \subsection{Extra utilities}
%    Some handy macros for numbering. If n>5, use |n\vet|.
% \begin{macro}{\kentan}
% \begin{macro}{\eil}
% \begin{macro}{\re}
% \begin{macro}{\trede}
% \begin{macro}{\pevare}
% \begin{macro}{\vet}
% \begin{macro}{\pempvet}
%    \begin{macrocode}
\def\kentan{1\textsuperscript{añ}}
\def\eil{2\textsuperscript{l}}
\def\re{\textsuperscript{e}}
\def\trede{3\re}
\def\pevare{4\re}
\def\vet{\textsuperscript{vet}}
\def\pempvet{5\vet}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    Some definitions for special characters.\\  We won’t define
%    |\tilde| as a Text Symbol not to conflict with the macro |\tilde|
%    for math mode and will use the breton name |\tildenn|instead.\\
%    Note that |\boi| may \emph{not} be used in math mode, its name in
%    math mode is |\backslash|. In Breton backslash is |\kilveskell|.\\
%    |\degre| can be poorly accessed by the command |\r{}| for ring
%    accent.  |\degre| is |\derez| in Breton.\\
%    ``\textasciicircum" alone (|\textasciicircum|) is coded
%    |\tiredkognek|.
%
%    \begin{macrocode}
\AtEndOfPackage{\RequirePackage{scalefnt}}
\if\bbl@engine>\z@
  \providecommand*{\textbackslash}{{\char"005C}}
  \providecommand*{\textasciicircum}{{\char"005E}}
  \providecommand*{\textasciitilde}{{\char"007E}}
  \DeclareRobustCommand*{\derez}{°}
\else
  \DeclareRobustCommand*{\derez}{\textdegree}
\fi
\DeclareRobustCommand*{\boi}{\textbackslash}% keep it for french users
\DeclareRobustCommand*{\kilveskell}{\textbackslash}% OPLB
\DeclareRobustCommand*{\tiredkognek}{\textasciicircum}% OPLB
\DeclareRobustCommand*{\tildenn}{\textasciitilde}% OPLB
%    \end{macrocode}
%
% \begin{macro}{\Ker}
% \begin{macro}{\kerbihan}
%    Stroked K (and k), |\Ker| (and |\kerbihan|), give an Unicode glyph
%    if it exists in font, else overlapped K/.
%    \begin{macrocode}
\NewDocumentCommand{\Ker}{O{.5}O{.7}}{
  \ifnum\bbl@engine > \z@
    \iffontchar\font "A742 \char"A742 \relax
    \else
      \settowidth{\@tempdima}{K}%
  \makebox[0pt][l]{\hskip#1\@tempdima\raisebox{-.1ex}{\scalefont{#2}/}}K%
    \fi
  \else
    \settowidth{\@tempdima}{K}%
  \makebox[0pt][l]{\hskip#1\@tempdima\raisebox{-.1ex}{\scalefont{#2}/}}K%
  \fi
}%K barrennet
\NewDocumentCommand{\kerbihan}{O{.6}O{.5}}{%
  \ifnum\bbl@engine > \z@
    \iffontchar\font "A743 \char"A743 \relax
    \else
      \settowidth{\@tempdima}{k}%
  \makebox[0pt][l]{\hskip#1\@tempdima\raisebox{-.1ex}{\scalefont{#2}/}}k%%
    \fi
  \else
    \settowidth{\@tempdima}{k}%
  \makebox[0pt][l]{\hskip#1\@tempdima\raisebox{-.1ex}{\scalefont{#2}/}}k%%
  \fi
}%k barrennet
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%  \subsection{Clean up and exit}
%
%    Final cleaning.
%    The macro |\ldf@finish| takes care for setting the main language
%    to be switched on at |\begin{document}| and resetting the
%    category code of \texttt{@} to its original value.
%    \begin{macrocode}
\ldf@finish{breton}
%    \end{macrocode}
% \iffalse
%</ldf>
% \fi
%
% \Finale
%
\endinput

%%% Local Variables:
%%% fill-column: 72
%%% coding: utf-8
%%% mode: doctex
%%% TeX-engine: luatex
%%% End:
