%% File `varioref-korean.sty`
%%
%% (C) Copyright 2024 강우현 <kangwh.2003 at gmail.com>
%%
%% This work 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 2006/05/20 or later.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{varioref-korean}[2024/03/31 Korean localisation of varioref package]

\newif\if@setlabelformat \@setlabelformatfalse
\DeclareOption{setlabel}{\@setlabelformattrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{varioref}}
\ProcessOptions\relax
\RequirePackage{varioref}

\newif\ifUI \UItrue
\def\kvr@ui{\ifUI 의\else\fi}
\def\kvr@eitneun{\ifUI 에 있는\else\fi}

\def\reftextfaceafter{\reftextvario{오른쪽 페이지}{옆 쪽}\kvr@ui}
\def\reftextfacebefore{\reftextvario{왼쪽 페이지}{옆 쪽}\kvr@ui}
\def\reftextafter{\reftextvario{다음 쪽}{뒤쪽}\kvr@ui}
\def\reftextbefore{\reftextvario{이전 쪽}{앞쪽}\kvr@ui}
\def\reftextcurrent{현재 페이지\kvr@ui}
\def\reftextfaraway#1{\pageref{#1}쪽\kvr@ui}
\def\reftextpagerange#1#2{\pageref{#1}\~{}\pageref{#2}쪽\kvr@eitneun}
\def\reftextlabelrange#1#2{\ref{#1}\~{}\ref{#2}}

\def\vrefformat#1#2{\vpageref[#1]{#2} \ref{#2}}
\def\Vrefformat#1#2{\vpageref[#1]{#2} \ref{#2}}
\def\fullrefformat#1{\reftextfaraway{#1} \ref{#1}}
\def\vrefrangeformat#1#2#3{\vpagerefrange[{#1}]{#2}{#3} \reftextlabelrange{#2}{#3}}

\if@setlabelformat
  \labelformat{part}{제#1편}
  \labelformat{chapter}{제#1장}
  \labelformat{section}{#1절}
  \labelformat{figure}{그림~#1}
  \labelformat{table}{표~#1}
  \labelformat{footnote}{각주~#1}
\fi

\endinput