Bugzilla – Attachment 183566 Details for
Bug 36947
Sort Elasticsearch/Zebra facets according to configurable locale instead of using Perl's stringwise/bytewise sort
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36947: (QA follow-up) Add missing POD documentation to Koha::I18N
Bug-36947-QA-follow-up-Add-missing-POD-documentati.patch (text/plain), 5.95 KB, created by
David Cook
on 2025-06-27 00:47:00 UTC
(
hide
)
Description:
Bug 36947: (QA follow-up) Add missing POD documentation to Koha::I18N
Filename:
MIME Type:
Creator:
David Cook
Created:
2025-06-27 00:47:00 UTC
Size:
5.95 KB
patch
obsolete
>From 6bcec0ba98306e5dc775d6e837279532870a0759 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 26 Jun 2025 17:41:00 +0100 >Subject: [PATCH] Bug 36947: (QA follow-up) Add missing POD documentation to > Koha::I18N > >The Koha::I18N module was missing POD documentation. This adds complete >documentation for all exported functions including usage examples and >descriptions. > >Signed-off-by: David Cook <dcook@prosentient.com.au> >--- > Koha/I18N.pm | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 163 insertions(+) > >diff --git a/Koha/I18N.pm b/Koha/I18N.pm >index e49e2e430a..3fbbabe685 100644 >--- a/Koha/I18N.pm >+++ b/Koha/I18N.pm >@@ -59,6 +59,45 @@ our @EXPORT_OK = qw( > > our $textdomain = 'Koha'; > >+=head1 NAME >+ >+Koha::I18N - Internationalization functions for Koha >+ >+=head1 SYNOPSIS >+ >+ use Koha::I18N; >+ >+ # Basic translation functions >+ my $translated = __('Hello world'); >+ my $with_vars = __x('Hello {name}', name => 'World'); >+ my $plural = __n('one item', '{count} items', $count, count => $count); >+ >+ # Context-aware translations >+ my $context = __p('menu', 'File'); >+ >+ # Get available system locales (explicitly imported) >+ use Koha::I18N qw(available_locales); >+ my $locales = available_locales(); >+ >+=head1 DESCRIPTION >+ >+This module provides internationalization (i18n) functions for Koha using the >+GNU gettext system. It handles locale setup, message translation, and provides >+utility functions for working with system locales. >+ >+The module automatically initializes the locale environment and provides a set >+of translation functions that support variable substitution, plural forms, and >+contextual translations. >+ >+=head1 FUNCTIONS >+ >+=head2 init >+ >+Initializes the internationalization system by setting up locale environment >+variables and configuring gettext. This is called automatically when needed. >+ >+=cut >+ > sub init { > my $cache = Koha::Cache::Memory::Lite->get_instance(); > my $cache_key = 'i18n:initialized'; >@@ -96,6 +135,14 @@ sub init { > } > } > >+=head2 __ >+ >+ my $translated = __('Text to translate'); >+ >+Basic translation function. Returns the translated text for the given message ID. >+ >+=cut >+ > sub __ { > my ($msgid) = @_; > >@@ -104,6 +151,15 @@ sub __ { > return _gettext( \&gettext, [$msgid] ); > } > >+=head2 __x >+ >+ my $translated = __x('Hello {name}', name => 'World'); >+ >+Translation with variable substitution. Variables in {brackets} are replaced >+with the corresponding values from the provided hash. >+ >+=cut >+ > sub __x { > my ( $msgid, %vars ) = @_; > >@@ -112,6 +168,14 @@ sub __x { > return _gettext( \&gettext, [$msgid], %vars ); > } > >+=head2 __n >+ >+ my $translated = __n('one item', '{count} items', $count); >+ >+Plural-aware translation. Returns singular or plural form based on the count. >+ >+=cut >+ > sub __n { > my ( $msgid, $msgid_plural, $count ) = @_; > >@@ -121,6 +185,14 @@ sub __n { > return _gettext( \&ngettext, [ $msgid, $msgid_plural, $count ] ); > } > >+=head2 __nx >+ >+ my $translated = __nx('one item', '{count} items', $count, count => $count); >+ >+Plural-aware translation with variable substitution. >+ >+=cut >+ > sub __nx { > my ( $msgid, $msgid_plural, $count, %vars ) = @_; > >@@ -130,10 +202,25 @@ sub __nx { > return _gettext( \&ngettext, [ $msgid, $msgid_plural, $count ], %vars ); > } > >+=head2 __xn >+ >+Alias for __nx. >+ >+=cut >+ > sub __xn { > return __nx(@_); > } > >+=head2 __p >+ >+ my $translated = __p('context', 'Text to translate'); >+ >+Context-aware translation. Allows the same text to be translated differently >+based on context (e.g., 'File' in a menu vs 'File' as a document type). >+ >+=cut >+ > sub __p { > my ( $msgctxt, $msgid ) = @_; > >@@ -143,6 +230,14 @@ sub __p { > return _gettext( \&pgettext, [ $msgctxt, $msgid ] ); > } > >+=head2 __px >+ >+ my $translated = __px('context', 'Hello {name}', name => 'World'); >+ >+Context-aware translation with variable substitution. >+ >+=cut >+ > sub __px { > my ( $msgctxt, $msgid, %vars ) = @_; > >@@ -152,6 +247,14 @@ sub __px { > return _gettext( \&pgettext, [ $msgctxt, $msgid ], %vars ); > } > >+=head2 __np >+ >+ my $translated = __np('context', 'one item', '{count} items', $count); >+ >+Context-aware plural translation. >+ >+=cut >+ > sub __np { > my ( $msgctxt, $msgid, $msgid_plural, $count ) = @_; > >@@ -162,6 +265,14 @@ sub __np { > return _gettext( \&npgettext, [ $msgctxt, $msgid, $msgid_plural, $count ] ); > } > >+=head2 __npx >+ >+ my $translated = __npx('context', 'one item', '{count} items', $count, count => $count); >+ >+Context-aware plural translation with variable substitution. >+ >+=cut >+ > sub __npx { > my ( $msgctxt, $msgid, $msgid_plural, $count, %vars ) = @_; > >@@ -172,18 +283,51 @@ sub __npx { > return _gettext( \&npgettext, [ $msgctxt, $msgid, $msgid_plural, $count ], %vars ); > } > >+=head2 N__ >+ >+ my $msgid = N__('Text for later translation'); >+ >+No-operation translation marker. Returns the original text unchanged but marks >+it for extraction by translation tools. >+ >+=cut >+ > sub N__ { > return $_[0]; > } > >+=head2 N__n >+ >+ my $msgid = N__n('singular', 'plural'); >+ >+No-operation plural translation marker. >+ >+=cut >+ > sub N__n { > return $_[0]; > } > >+=head2 N__p >+ >+ my $msgid = N__p('context', 'Text for later translation'); >+ >+No-operation context translation marker. >+ >+=cut >+ > sub N__p { > return $_[1]; > } > >+=head2 N__np >+ >+ my $msgid = N__np('context', 'singular', 'plural'); >+ >+No-operation context plural translation marker. >+ >+=cut >+ > sub N__np { > return $_[1]; > } >@@ -323,4 +467,23 @@ sub available_locales { > return \@available_locales; > } > >+=head1 AUTHOR >+ >+Koha Development Team >+ >+=head1 COPYRIGHT >+ >+Copyright 2012-2014 BibLibre >+ >+=head1 LICENSE >+ >+This file is part of Koha. >+ >+Koha is free software; you can redistribute it and/or modify it under the >+terms of the GNU General Public License as published by the Free Software >+Foundation; either version 3 of the License, or (at your option) any later >+version. >+ >+=cut >+ > 1; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36947
:
167110
|
167125
|
167141
|
167142
|
167143
|
167145
|
167146
|
167188
|
167198
|
167880
|
168488
|
170489
|
183551
|
183552
|
183553
|
183563
|
183564
|
183565
| 183566 |
183567
|
183568
|
183726
|
183727