Skip to content

Commit 682acd6

Browse files
committed
Detailed YARD documentation about the various Locale code standards used for each key/context
+ Split locale.rb and locales.rb
1 parent 5e80651 commit 682acd6

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module Fastlane
2+
# Defines a single Locale with the various locale codes depending on the representation needed.
3+
#
4+
# The various locale codes formats for the various keys can be found as follows:
5+
#
6+
# - glotpress:
7+
# Go to the GP project page (e.g. https://translate.wordpress.org/projects/apps/android/dev/)
8+
# and hover over the link for each locale, locale code is in the URL.
9+
# - android: (`values-*` folder names)
10+
# See https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources (Scroll to Table 2)
11+
# [ISO639-1 (lowercase)]-r[ISO-3166-alpha-2 (uppercase)], e.g. `zh-rCN` ("Chinese understood in mainland China")
12+
# - google_play: (PlayStore Console, for metadata, release_notes.xml and `fastlane supply`)
13+
# See https://support.google.com/googleplay/android-developer/answer/9844778 (then open "View list of available languages").
14+
# See also https://github.com/fastlane/fastlane/blob/master/supply/lib/supply/languages.rb
15+
# - ios: (`*.lproj`)
16+
# See https://developer.apple.com/documentation/xcode/choosing-localization-regions-and-scripts#Understand-the-Language-Identifier
17+
# [ISO639-1/ISO639-2 (lowercase)]-[ISO 3166-1 (uppercase region or titlecase script)], e.g. `zh-Hans` ("Simplified Chinese" script)
18+
# - app_store: (AppStoreConnect, for metadata and `fastlane deliver`)
19+
# See https://github.com/fastlane/fastlane/blob/master/deliver/lib/deliver/languages.rb
20+
#
21+
# Links to ISO Standards
22+
# ISO standard portal: https://www.iso.org/obp/ui/#search
23+
# ISO 639-1: https://www.loc.gov/standards/iso639-2/php/code_list.php
24+
# ISO-3166-alpha2: https://www.iso.org/obp/ui/#iso:pub:PUB500001:en
25+
#
26+
# Notes about region vs script codes in ISO-3166-1
27+
# `zh-CN` is a locale code - Chinese understood in mainland China
28+
# `zh-Hans` is a language+script code - Chinese written in Simplified Chinese (not just understood in mainland China)
29+
#
30+
Locale = Struct.new(:glotpress, :android, :google_play, :ios, :app_store, keyword_init: true) do
31+
# Returns the Locale with the given glotpress locale code from the list of all known locales (`Locales.all`)
32+
#
33+
# @param [String] The glotpress locale code for the locale to fetch
34+
# @return [Locale] The locale found
35+
# @raise [RuntimeException] if the locale with given glotpress code is unknown
36+
def self.[](code)
37+
Locales[code].first
38+
end
39+
end
40+
end

lib/fastlane/plugin/wpmreleasetoolkit/models/locales.rb

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
module Fastlane
2-
# Define a single Locale with the various locale codes depending on the representation needed
3-
Locale = Struct.new(:glotpress, :android, :google_play, :ios, :app_store, keyword_init: true) do
4-
# Returns the Locale with the given glotpress locale code from the list of all known locales (`Locales.all`)
5-
#
6-
# @param [String] The glotpress locale code for the locale to fetch
7-
# @return [Locale] The locale found
8-
# @raise [RuntimeException] if the locale with given glotpress code is unknown
9-
def self.[](code)
10-
Locales[code].first
11-
end
12-
end
1+
require_relative 'locale'
132

3+
module Fastlane
144
# A class with static methods to manipulate lists of locales.
5+
#
156
# Exposes various `Array<Locale>` lists like all known locales, the Mag16,
167
# and convenience methods to turn list of Strings into list of Locales.
8+
#
179
class Locales
1810
###################
1911
## Constants

0 commit comments

Comments
 (0)