20

In Turkish (and possibly in other similar languages), there are suffixes that change corresponding to the word they are applied. This also holds for the numbers.

For example,

in Figure \ref{fig1}

is written in Turkish as follows:

Şekil \ref{fig1}'de

The problem here is that the suffix "de" should change according to the number rendered before it. It should be like

1'de, 2'de, 3'te, 4'te, 5'te, 6'da, ..., 60'ta, ..., 70'te, ...

I don't like to check the suffixes manually after finishing the paper. This also happens for the other cross-references like equations.

How can I do this in LaTeX?

Edit: I'm adding the complete rule as @egreg asks. The determining numbers are as follows:

0'da
1'de
2'de
3'te
4'te
5'te
6'da
7'de
8'de
9'da
10'da
20'de
30'da
40'da
50'de
60'ta
70'te
80'de
90'da
100'de
1000'de
1000000'da
1000000000'da

For all the others, the number at the end determines the suffix if it is non-zero. For example

1234'te  (4'te)
303'te (3'te)

But, if there's a zero at the end and the number is not zero, then the right-most non-zero digit determines the result:

230'da (30'da)
200'de (100'de)
4000'de (1000'de)
40000'de (1000'de)
400000'de (1000'de)
4000000'da (1000000'da)

The suffix is determined by the last read word. For example 40000 is read as "kırk bin" and it becomes "40000'de". It is the same as "1000'de" which is read as "binde".

9
  • 2
    Can you spell out the complete rule?
    – egreg
    Feb 15, 2013 at 11:16
  • 1
    are these suffixes like the ordinal suffixes in english -- 1st 2nd 3rd 4th ... 11th ... 21st (and so on)? Feb 15, 2013 at 11:53
  • Yes, they are like the ordinal suffixes in English.
    – petrichor
    Feb 15, 2013 at 12:57
  • 1
    I've added the full spec.
    – petrichor
    Feb 15, 2013 at 13:09
  • 1
    The package fmtcount can be of use. I have to go now, but later (3 hours maybe) I'll prepare an .def file for this Turkish rules (unless someone else does so).
    – yo'
    Feb 15, 2013 at 13:17

4 Answers 4

12

This is a possible implementation using LaTeX3:

\documentclass{article}
\usepackage[turkish]{babel}
\usepackage{refcount}
\usepackage{xparse}

\usepackage{multicol} % only needed for the test

\ExplSyntaxOn
\NewDocumentCommand{\turkishref}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \turksuf_suffix_get:n { #2 }
 }

\seq_new:N \l__turksuf_ref_seq
\tl_new:N \l__turksuf_ref_tl
\cs_new_protected:Npn \turksuf_suffix_get:n #1
 {
  \seq_set_split:Nnx \l__turksuf_ref_seq { . } { \getrefnumber { #1 } }
  \seq_pop_right:NN \l__turksuf_ref_seq \l__turksuf_ref_tl
  \turksuf_suffix:V \l__turksuf_ref_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\NewDocumentCommand{\turkishsuffix}{m}
 {
  \turksuf_suffix:n { #1 }
 }

\cs_new:Npn \turksuf_suffix:n #1
 {
  \int_compare:nTF { #1 == 0 } { 'da } { \turksuf_nonzero:n { #1 } }
 }
\cs_new:Npn \turksuf_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'de}
    {2}{'de}
    {3}{'te}
    {4}{'te}
    {5}{'te}
    {6}{'da}
    {7}{'de}
    {8}{'de}
    {9}{'da}
    {10}{'da}
    {20}{'de}
    {30}{'da}
    {40}{'da}
    {50}{'de}
    {60}{'da}
    {70}{'de}
    {80}{'de}
    {90}{'da}
    {100}{'de}
    {1000}{'de}
   }
   {
    \turksuf_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \turksuf_suffix:n { V }

\cs_new:Npn \turksuf_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \turksuf_complex_ten:n { #1 } }
   { \turksuf_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }

\cs_new:Npn \turksuf_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \turksuf_complex_hundred:n { #1 } }
   { \turksuf_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \turksuf_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \turksuf_complex_thousand:n { #1 } }
   { 'de }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 1000 } } }
 }
\cs_new:Npn \turksuf_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \turksuf_complex_tenthousand:n { #1 } }
   { 'de }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 10000 } } }
 }
\cs_new:Npn \turksuf_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \turksuf_complex_hundredthousand:n { #1 } }
   { 'de }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 100000 } } }
 }
\cs_new:Npn \turksuf_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \turksuf_complex_million:n { #1 } }
   { 'da }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 1000000 } } }
 }
\NewDocumentCommand\test{m}
 {
  \int_step_inline:nnnn { 0 } { 1 } { #1 }
   { ##1\turkishsuffix{##1}\par }
 }
\ExplSyntaxOff

\setlength{\parindent}{0pt} % just for the test

\begin{document}
\begin{multicols}{5}
\test{300}
\end{multicols}

\setcounter{figure}{12}
\begin{figure}
\caption{X}\label{A}
\end{figure}
\figurename~\turkishref{A}.

1234\turkishsuffix{1234}\\
1320\turkishsuffix{1320}\\
1330\turkishsuffix{1330}\\
1000\turkishsuffix{1000}\\
1003\turkishsuffix{1003}

\setcounter{section}{1}
\setcounter{subsection}{3}
\subsection{B}\label{B}

Subsection~\turkishref{B}

\end{document}

I show only the last lines with the reference to the figure and the following test cases.

NOTE Support for "composite numbers" has been added. Moreover, one has \turkishref* that calls \ref* instead of \ref (of course hyperref is needed for this to work).

enter image description here


Here is a packaged version of the code. Save as turkref.sty in any place searched by TeX programs, for instance in

~/texmf/tex/latex/turkref/

on GNU/Linux systems or

~/Library/texmf/tex/latex/turkref/

for Mac OS X.

\RequirePackage{expl3,xparse}
\ProvidesExplPackage{turkref}{2014/12/11}{0.1}{Turkish suffix for ref}

\@ifpackagelater { expl3 } { 2012/11/21 }
 { }
 {
  \PackageError { turkref } { Support~package~expl3~too~old }
   {
    You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
    'l3packages'.\MessageBreak
    Loading~turkref~will~abort!
   }
  \tex_endinput:D
 }

\RequirePackage{refcount}

% User commands
\NewDocumentCommand{\turkishref}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \turksuf_suffix_get:n { #2 }
 }

\NewDocumentCommand{\turkishsuffix}{m}
 {
  \turksuf_suffix:n { #1 }
 }

% Variables
\seq_new:N \l__turksuf_ref_seq
\tl_new:N \l__turksuf_ref_tl

\cs_new_eq:NN \turksuf_getrefnumber:n \getrefnumber

% Functions
\cs_new_protected:Npn \turksuf_suffix_get:n #1
 {
  \seq_set_split:Nnx \l__turksuf_ref_seq { . } { \turksuf_getrefnumber:n { #1 } }
  \seq_pop_right:NN \l__turksuf_ref_seq \l__turksuf_ref_tl
  \turksuf_suffix:V \l__turksuf_ref_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\cs_new:Npn \turksuf_suffix:n #1
 {
  \int_compare:nTF { #1 == 0 } { 'da } { \__turksuf_nonzero:n { #1 } }
 }

\cs_new:Npn \__turksuf_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'de}
    {2}{'de}
    {3}{'te}
    {4}{'te}
    {5}{'te}
    {6}{'da}
    {7}{'de}
    {8}{'de}
    {9}{'da}
    {10}{'da}
    {20}{'de}
    {30}{'da}
    {40}{'da}
    {50}{'de}
    {60}{'da}
    {70}{'de}
    {80}{'de}
    {90}{'da}
    {100}{'de}
    {1000}{'de}
   }
   {
    \__turksuf_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \turksuf_suffix:n { V }

\cs_new:Npn \__turksuf_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \__turksuf_complex_ten:n { #1 } }
   { \__turksuf_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }

\cs_new:Npn \__turksuf_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \__turksuf_complex_hundred:n { #1 } }
   { \__turksuf_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \__turksuf_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \__turksuf_complex_thousand:n { #1 } }
   { 'de }
 }
\cs_new:Npn \__turksuf_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \__turksuf_complex_tenthousand:n { #1 } }
   { 'de }
 }
\cs_new:Npn \__turksuf_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \__turksuf_complex_hundredthousand:n { #1 } }
   { 'de }
 }
\cs_new:Npn \__turksuf_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \__turksuf_complex_million:n { #1 } }
   { 'da }
 }

Now the test document can be

\documentclass{article}
\usepackage[turkish]{babel}
\usepackage{multicol}
\usepackage{turkref} % <--- load the package

\ExplSyntaxOn
% Just for testing not needed in real documents
\NewDocumentCommand\test{m}
 {
  \int_step_inline:nnnn { 0 } { 1 } { #1 }
   { ##1\turkishsuffix{##1}\par }
 }
\ExplSyntaxOff

\setlength{\parindent}{0pt} % just for the test

\begin{document}
\begin{multicols}{5}
\test{300}
\end{multicols}

\setcounter{figure}{12}
\begin{figure}
\caption{X}\label{A}
\end{figure}
\figurename~\turkishref{A}.

1234\turkishsuffix{1234}\\
1320\turkishsuffix{1320}\\
1330\turkishsuffix{1330}\\
1000\turkishsuffix{1000}\\
1003\turkishsuffix{1003}

\setcounter{section}{1}
\setcounter{subsection}{3}
\subsection{B}\label{B}

Subsection~\turkishref{B}

\end{document}
4
  • It gives an error at line 17 saying that: Illegal parameter number in definition of \turksuf_suffix_get:n: ...turksuf_ref_seq { . } { \getrefnumber { #2 .... How can I fix it?
    – petrichor
    Feb 17, 2013 at 21:32
  • @petrichor Sorry, a copy-paste error; the #2 should be #1; I'll fix it in a moment.
    – egreg
    Feb 17, 2013 at 21:39
  • It works perfect now with the composite numbers. Thank you very much.
    – petrichor
    Feb 17, 2013 at 21:47
  • Hey @egreg could you please take a look at this post? tex.stackexchange.com/questions/646940/…
    – WhoCares
    Jun 13, 2022 at 6:47
4

This tweaks into the package fmtcount and provides the numeric ordinals for turkish language.

First, save the following code as fc-turkish.tex (for example, the name does not matter). The official name inside the package fmtcount would be different, but I don't want to use the official one since this is not an official file of the package.

\makeatletter
\def\@OT@do#1#2#3#4#5#6#7\@OT@enddo{%
\ifcase0#1 % ~0
  \ifx\relax#2\relax% 0
    \def\@OT@suf{da}%
  \else
    \ifcase#2 % ~00
      \ifx0#3% ~000
        \ifx0#4% ~0000
          \ifx0#5% ~00000
            \ifx0#6% ~000000
              \def\@OT@suf{da}%
            \else % ~x00000
              \def\@OT@suf{de}%
            \fi
          \else % ~x0000
            \def\@OT@suf{de}%
          \fi
        \else % ~x000
          \def\@OT@suf{de}%
        \fi
      \else % ~x00
        \def\@OT@suf{de}%
      \fi
    \or% ~10
      \def\@OT@suf{da}%
    \or% ~20
      \def\@OT@suf{de}%
    \or% ~30
      \def\@OT@suf{da}%
    \or% ~40
      \def\@OT@suf{da}%
    \or% ~50
      \def\@OT@suf{de}%
    \or% ~60
      \def\@OT@suf{da}%
    \or% ~70
      \def\@OT@suf{de}%
    \or% ~80
      \def\@OT@suf{de}%
    \or% ~90
      \def\@OT@suf{da}%
    \fi
  \fi
\or% ~1
  \def\@OT@suf{de}%
\or% ~2
  \def\@OT@suf{de}%
\or% ~3
  \def\@OT@suf{te}%
\or% ~4
  \def\@OT@suf{te}%
\or% ~5
  \def\@OT@suf{te}%
\or% ~6
  \def\@OT@suf{da}%
\or% ~7
  \def\@OT@suf{de}%
\or% ~8
  \def\@OT@suf{de}%
\or% ~9
  \def\@OT@suf{da}%
\fi
}
\def\@OT@rev#1#2\revA#3\revB{%
  \if\relax\detokenize{#2}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi{#1#3}{\@OT@rev#2\revA#1#3\revB}}
\newcommand{\@ordinalMturkish}[1]{%
  \@orgargctr=#1\relax
  \@ordinalctr=#1%
  \edef\@OT@str{\the\@ordinalctr}%
  \edef\@OT@str{\expandafter\@OT@rev\@OT@str\revA\revB}%
  \expandafter\@OT@do\@OT@str\relax\relax\relax\relax\relax\relax\@OT@enddo
  \the\@orgargctr\fmtord{'\@OT@suf}%
}
\def\ordref#1{%
  \edef\@OD@ref{\csname r@#1\endcsname\relax}%
  \edef\@OD@num{\expandafter\@firstoftwo\@OD@ref}%
  \ifx\@OD@num\relax
    \@orgargctr0%
  \else
    \expandafter\@orgargctr0\@OD@num
  \fi
  \@ordinalMturkish\@orgargctr
}
\let\@ordinalFturkish=\@ordinalMturkish
\makeatother

Then, you can use the package fmtcount with turkish. Test document:

\documentclass[12pt, oneside]{article}
\usepackage[turkish]{babel}
\usepackage[level]{fmtcount}
\input{fc-turkish.tex}
\def\fmtord#1{#1}
\begin{document}

\ttfamily

\section{First}

\section{Hello World!}\label{sec2s}

In \ordref{sec2s} section, there is a test of package functionality:

\raggedright\ttfamily

\ordinal{section}
\loop
\ifnum\value{section}<1000
\refstepcounter{section}
\ordinal{section}
\repeat

\loop
\ifnum\value{section}<100000
\addtocounter{section}{1030}
\ordinal{section}
\repeat

\setcounter{section}{0}

\loop
\ifnum\value{section}<1000000
\addtocounter{section}{100000}
\ordinal{section}
\repeat

\end{document}

I apologize for not commenting the code. I'm actually not sure how I would comment it. Part is taken from fc-english.def and another part is a bunch of tests to get the right suffix. Only a small note: the macro \OT@do is fed the number to be typeset, but written reversed, so the least significant digit is got as #1. The macro \ordref won't work with nested numbers (2 is ok, 2.4 is not).

1
  • 1
    It gave an error for my case: Line 18: Undefined control sequence: <argument> ...e c@section\endcsname }{\@fc@ordstr : \ordinal{section}. I am using Miktex on Windows and generating via pdflatex. I saved the file with the name you gave and trying to compile the second file.
    – petrichor
    Feb 17, 2013 at 21:43
1

This is a rookie's approach to the problem (The rookie is me). It doesn't use LaTeX3. It handles more suffix types. I made it into a simple package. It requires packages etoolbox, xparse, xstring, and refcount

Usage notes on package reftr

reftr package replaces \ref command by default. 
If you don't want this behaviour simply comment the last line of the package.
Then you will have to use \reftr command for suffixed cross references.
This package should also work with composite numbers (such as "2.12").

reftr package also defines \trnumdecorator macro for suffixing numbers.

Usage of \ref (or \reftr if not replaced):

To produce only the label number (original \ref behavior):
\ref{(label name)} 

To produce label number with a suffix:
\ref{label name}{suffix}

suffix should be defined as if it was for number "1". Allowed suffixes are:
 - de
 - den
 - e
 - i
 - in

Examples (assuming the figure with label "fig:figure3" is the third figure):

\ref{fig:figure3}       %This will output "3"
\ref{fig:figure3}{de}   %This will output "3'te"
\ref{fig:figure3}{den}  %This will output "3'ten"
\ref{fig:figure3}{e}    %This will output "3'e"
\ref{fig:figure3}{i}    %This will output "3'ü"
\ref{fig:figure3}{in}   %This will output "3'ün"

Errors:

If \ref{}{} comes accross a number that it can't handle it will produce "3'??"
If a wrong suffix is input it will produce "'?unknwnSfx"

\ref{fig:figure3}{ün} %This will output "3'?unknwnSfx"

Usage of \trnumdecorator:

\trnumdecorator{argument-that-ends-with-number}{suffix}

suffix should be defined as if it was for number "1". Allowed suffixes are:
 - de
 - den
 - e
 - i
 - in

The stared version \trnumdecorator* will only produce the suffix

Example:

\trnumdecorator{blabla20}{in}   %This will output "blabla20'nin"
\trnumdecorator*{blabla20}{in}  %This will output "'nin"

Note: \trnumdecorator* is what \ref uses for suffixing numbers

Package Code

Don't be harsh on me, I am a newbie

\ProvidesPackage{reftr}


\RequirePackage{etoolbox}
\RequirePackage{xparse}
\RequirePackage{xstring}
\RequirePackage{refcount}

\csdef{trsuf1de}{de}
\csdef{trsuf2de}{de}
\csdef{trsuf3de}{te}
\csdef{trsuf4de}{te}
\csdef{trsuf5de}{te}
\csdef{trsuf6de}{da}
\csdef{trsuf7de}{de}
\csdef{trsuf8de}{de}
\csdef{trsuf9de}{da}
\csdef{trsuf10de}{da}
\csdef{trsuf20de}{de}
\csdef{trsuf30de}{da}
\csdef{trsuf40de}{ta}
\csdef{trsuf50de}{de}
\csdef{trsuf60de}{ta}
\csdef{trsuf70de}{te}
\csdef{trsuf80de}{de}
\csdef{trsuf90de}{da}
\csdef{trsuf100de}{de}
\csdef{trsuf1000de}{de}

\csdef{trsuf1den}{den}
\csdef{trsuf2den}{den}
\csdef{trsuf3den}{ten}
\csdef{trsuf4den}{ten}
\csdef{trsuf5den}{ten}
\csdef{trsuf6den}{dan}
\csdef{trsuf7den}{den}
\csdef{trsuf8den}{den}
\csdef{trsuf9den}{dan}
\csdef{trsuf10den}{dan}
\csdef{trsuf20den}{den}
\csdef{trsuf30den}{dan}
\csdef{trsuf40den}{tan}
\csdef{trsuf50den}{den}
\csdef{trsuf60den}{tan}
\csdef{trsuf70den}{ten}
\csdef{trsuf80den}{den}
\csdef{trsuf90den}{dan}
\csdef{trsuf100den}{den}
\csdef{trsuf1000den}{den}

\csdef{trsuf1e}{e}
\csdef{trsuf2e}{ye}
\csdef{trsuf3e}{e}
\csdef{trsuf4e}{e}
\csdef{trsuf5e}{e}
\csdef{trsuf6e}{ya}
\csdef{trsuf7e}{ye}
\csdef{trsuf8e}{e}
\csdef{trsuf9e}{a}
\csdef{trsuf10e}{a}
\csdef{trsuf20e}{ye}
\csdef{trsuf30e}{a}
\csdef{trsuf40e}{a}
\csdef{trsuf50e}{ye}
\csdef{trsuf60e}{a}
\csdef{trsuf70e}{e}
\csdef{trsuf80e}{e}
\csdef{trsuf90e}{a}
\csdef{trsuf100e}{e}
\csdef{trsuf1000e}{e}

\csdef{trsuf1i}{i}
\csdef{trsuf2i}{yi}
\csdef{trsuf3i}{ü}
\csdef{trsuf4i}{ü}
\csdef{trsuf5i}{i}
\csdef{trsuf6i}{yı}
\csdef{trsuf7i}{yi}
\csdef{trsuf8i}{i}
\csdef{trsuf9i}{u}
\csdef{trsuf10i}{u}
\csdef{trsuf20i}{yi}
\csdef{trsuf30i}{u}
\csdef{trsuf40i}{ı}
\csdef{trsuf50i}{yi}
\csdef{trsuf60i}{ı}
\csdef{trsuf70i}{i}
\csdef{trsuf80i}{i}
\csdef{trsuf90i}{ı}
\csdef{trsuf100i}{ü}
\csdef{trsuf1000i}{i}

\csdef{trsuf1in}{in}
\csdef{trsuf2in}{nin}
\csdef{trsuf3in}{ün}
\csdef{trsuf4in}{ün}
\csdef{trsuf5in}{in}
\csdef{trsuf6in}{nın}
\csdef{trsuf7in}{nin}
\csdef{trsuf8in}{in}
\csdef{trsuf9in}{un}
\csdef{trsuf10in}{un}
\csdef{trsuf20in}{nin}
\csdef{trsuf30in}{un}
\csdef{trsuf40in}{ın}
\csdef{trsuf50in}{nin}
\csdef{trsuf60in}{ın}
\csdef{trsuf70in}{in}
\csdef{trsuf80in}{in}
\csdef{trsuf90in}{ın}
\csdef{trsuf100in}{ün}
\csdef{trsuf1000in}{in}

\NewDocumentCommand \trnumdecorator {s m m}{%
    \IfBooleanTF {#1}{}{#2}%
    \csdef{rtLstDgt}{?}%    
    \IfEndWith{#2}{1}{\csdef{rtLstDgt}{1}}{}%
    \IfEndWith{#2}{2}{\csdef{rtLstDgt}{2}}{}%
    \IfEndWith{#2}{3}{\csdef{rtLstDgt}{3}}{}%
    \IfEndWith{#2}{4}{\csdef{rtLstDgt}{4}}{}%
    \IfEndWith{#2}{5}{\csdef{rtLstDgt}{5}}{}%
    \IfEndWith{#2}{6}{\csdef{rtLstDgt}{6}}{}%
    \IfEndWith{#2}{7}{\csdef{rtLstDgt}{7}}{}%
    \IfEndWith{#2}{8}{\csdef{rtLstDgt}{8}}{}%
    \IfEndWith{#2}{9}{\csdef{rtLstDgt}{9}}{}%
    \IfEndWith{#2}{10}{\csdef{rtLstDgt}{10}}{}%
    \IfEndWith{#2}{20}{\csdef{rtLstDgt}{20}}{}%
    \IfEndWith{#2}{30}{\csdef{rtLstDgt}{30}}{}%
    \IfEndWith{#2}{40}{\csdef{rtLstDgt}{40}}{}%
    \IfEndWith{#2}{50}{\csdef{rtLstDgt}{50}}{}%
    \IfEndWith{#2}{60}{\csdef{rtLstDgt}{60}}{}%
    \IfEndWith{#2}{70}{\csdef{rtLstDgt}{70}}{}%
    \IfEndWith{#2}{80}{\csdef{rtLstDgt}{80}}{}%
    \IfEndWith{#2}{90}{\csdef{rtLstDgt}{90}}{}%
    \IfEndWith{#2}{00}{\csdef{rtLstDgt}{100}}{}%
    \IfEndWith{#2}{000}{\csdef{rtLstDgt}{1000}}{}%
    %\IfEq{\csuse{rtLstDgt}}{?}{'??}{'\csuse{trsuf\csuse{rtLstDgt}#3}}%Comment the line below and uncomment this one if you don't want ?unknwnSfx to be produced
    \IfEq{\csuse{rtLstDgt}}{?}{'??}{'\ifcsdef{trsuf\csuse{rtLstDgt}#3}    {\csuse{trsuf\csuse{rtLstDgt}#3}}{?unknwnSfx}}%       
}%

\let\oldref=\ref %this is added to allow converting \ref into \reftr

\NewDocumentCommand \reftr {m g}{%
    \oldref{#1}%
    \IfNoValueTF{#2}{}{%
        \trnumdecorator*{\getrefnumber{#1}}{#2}%        
    }%
}%

\let\ref=\reftr %this line makes \ref work as \reftr
0

This is an extension of @egreg's answer leveraging the flexibility of zref (through zref-clever), so that there's no need to use dedicated reference commands. We build a zref property which includes the suffix, and then we can make references like any other ones. (With all the goodies of using standard reference commands).

\documentclass{article}

\usepackage[turkish]{babel}
\usepackage{turkref} % by 'egreg': https://tex.stackexchange.com/a/98366/105447

\usepackage{zref-clever}
\zcDeclareLanguage{turkish}
\zcLanguageSetup{turkish}{
  type=section,
    name-sg=Bölüm, % ???
  type=figure,
    name-sg=Şekil, % ???
}

% creating the reference property
\makeatletter
\zref@newprop{turkishref}{%
  \@currentlabel\turkishsuffix{\arabic{\@currentcounter}}}
\zref@addprop{main}{turkishref}
\makeatother

% Set default ref property to turkishref
\zcsetup{ref=turkishref}

\begin{document}

\setcounter{figure}{6}
\begin{figure}
\caption{X}
\zlabel{A}
\end{figure}

\setcounter{section}{1}
\setcounter{subsection}{14}
\subsection{B}
\zlabel{B}

\zcref{A}

\zcref{B}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .