<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cristian Lupu on Medium]]></title>
        <description><![CDATA[Stories by Cristian Lupu on Medium]]></description>
        <link>https://medium.com/@cristilupu?source=rss-fec1cff93cc1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UnbhlDvGJmajlzrnMiLo0g.jpeg</url>
            <title>Stories by Cristian Lupu on Medium</title>
            <link>https://medium.com/@cristilupu?source=rss-fec1cff93cc1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:29:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cristilupu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[FuncCheck — Test your methods]]></title>
            <link>https://medium.com/crunchyroll/funccheck-test-your-methods-5be99032b909?source=rss-fec1cff93cc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5be99032b909</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[crunchyroll]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Cristian Lupu]]></dc:creator>
            <pubDate>Thu, 02 Dec 2021 12:51:45 GMT</pubDate>
            <atom:updated>2021-12-02T12:59:56.486Z</atom:updated>
            <content:encoded><![CDATA[<h3>FuncCheck — Test your methods</h3><h3><strong>Introduction</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AktzTtx2ZOH1kb8yv7Piw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@max_duz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Max Duzij</a> on <a href="https://unsplash.com/s/photos/programming?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When we are writing unit tests in a BDD style, we may want to check with what value parameter was called a dependency method or how many times that dependency method was called after some action in your testing instance.</p><p>And we often end up writing code like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11381d35b47e319a7368329fcf8bff0e/href">https://medium.com/media/11381d35b47e319a7368329fcf8bff0e/href</a></iframe><p>Looks like A LOT of boilerplate.</p><h3>Develop FuncCheck class</h3><blockquote>The iOS team uses an internal framework with test helpers and the <strong>FuncCheck</strong> class is one of them.</blockquote><p>What if we encapsulate all of this logic in one class? Let’s begin. The final interface should look more elegant:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c22bb4ccc946084208ce4eb58f6cfeab/href">https://medium.com/media/c22bb4ccc946084208ce4eb58f6cfeab/href</a></iframe><p>And how are we gonna use it in a test? We will surely need call count, a computed property to determine if this method was called, and the stack of invocations along with its parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/339d51731d1b638f2b95747a95163574/href">https://medium.com/media/339d51731d1b638f2b95747a95163574/href</a></iframe><p>This class should not be tied to a concrete type of parameter, and for that, we will use generics. Let’s add the call count:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e098e757cec4b35bc071243b59d52ed3/href">https://medium.com/media/e098e757cec4b35bc071243b59d52ed3/href</a></iframe><p>Easy enough. Using <strong>callCount</strong> facilitates the creation of a computed property named <strong>wasCalled.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0e8a1040ab2933bf4195bff52d044a8/href">https://medium.com/media/c0e8a1040ab2933bf4195bff52d044a8/href</a></iframe><p>Next, we need to implement the stack of invocations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c39aeaf2e9f84fc98f4aec3727870f43/href">https://medium.com/media/c39aeaf2e9f84fc98f4aec3727870f43/href</a></iframe><p>Most of the time, we will not need the whole stack but only the last:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00b37d20ccb1e69ca1e02f0fd22baf24/href">https://medium.com/media/00b37d20ccb1e69ca1e02f0fd22baf24/href</a></iframe><p>Now, we can implement a handy method <strong>wasCalled(with:)</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90dd928515bceb12b5a3e77ad8397211/href">https://medium.com/media/90dd928515bceb12b5a3e77ad8397211/href</a></iframe><p>Another method that may be useful in testing is getting a callback when the invocation started.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8c24fe060c0d53115a81311fc95c11b/href">https://medium.com/media/c8c24fe060c0d53115a81311fc95c11b/href</a></iframe><p>Another wish in testing is checking whether a method was called after or before another method. The implementation is simple: we create a private date variable and reset it on every call, then we can compare dates with other ones.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7036c92d1f299baf242b3c165908918/href">https://medium.com/media/f7036c92d1f299baf242b3c165908918/href</a></iframe><h4>What if your methods don’t accept any parameters?</h4><p>You can still use <strong>FuncCheck&lt;Void&gt;</strong> or a sugar extension over <strong>FuncCheck</strong> class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f07e9688849b2122b33d13f6a4025375/href">https://medium.com/media/f07e9688849b2122b33d13f6a4025375/href</a></iframe><h4>What if your methods accept more than one argument? How can I use FuncCheck if there is only one generic parameter?</h4><p>In this case, the best solution is to use Swift tuples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03a9dedceac6ffe9e83bed06cb9e44b0/href">https://medium.com/media/03a9dedceac6ffe9e83bed06cb9e44b0/href</a></iframe><h4><strong>Are you using Nimble in your testing?</strong></h4><p>We’ve prepared some extensions to facilitate the <strong>FuncCheck</strong> usage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42b875305477475c103373f0a11152e0/href">https://medium.com/media/42b875305477475c103373f0a11152e0/href</a></iframe><p>Let’s see how it looks in the battle:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fcdd5ea6c7dc5c5a8d2c4cfff87dd5d/href">https://medium.com/media/4fcdd5ea6c7dc5c5a8d2c4cfff87dd5d/href</a></iframe><h4>Stub the return values of the method</h4><p>What if your method has a return value and you also want to stub that value?<br>We propose this solution:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ace12974f048483d26bef5d96c55098/href">https://medium.com/media/5ace12974f048483d26bef5d96c55098/href</a></iframe><h3>Conclusion</h3><p>The <strong>FuncCheck</strong> was developed to facilitate writing the tests and their readability. Another solution to this is using code generation. An example is the <a href="https://github.com/krzysztofzablocki/Sourcery">Sourcery</a> with the <a href="https://github.com/krzysztofzablocki/Sourcery/blob/master/Templates/Templates/AutoMockable.stencil">AutoMockable</a> template. Thus every class needed to be mocked will have these properties and methods from code generation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5be99032b909" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crunchyroll/funccheck-test-your-methods-5be99032b909">FuncCheck — Test your methods</a> was originally published in <a href="https://medium.com/crunchyroll">Crunchyroll</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crunchyroll iOS i18n]]></title>
            <link>https://medium.com/crunchyroll/crunchyroll-ios-i18n-f6dee0c4afdd?source=rss-fec1cff93cc1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6dee0c4afdd</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[internationalization]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[crunchyroll]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Cristian Lupu]]></dc:creator>
            <pubDate>Fri, 29 Oct 2021 05:01:03 GMT</pubDate>
            <atom:updated>2021-10-29T05:01:03.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iqjN0HCegY4PNBGreQN8LA.jpeg" /><figcaption>Crunchyroll iOS</figcaption></figure><h3>Introduction</h3><p>In order to launch the new Crunchyroll iOS app into international countries we needed to implement internationalization, or for short i18n. We pursued the following objectives for selecting an i18n platform:</p><ul><li>Our app platforms (web, mobile, living room) should have almost the same flow of adding and modifying the strings.</li><li>Load the new and updated strings on each app startup.</li><li>Allow the team of translators to review and sign off the updated strings.</li><li>Possibility to download translations and bundle them into the app in case of offline mode.</li></ul><p>After extensive internal research on various TMS services available we decided to go with <a href="https://www.transifex.com/">Transifex</a> service.</p><h3>A bit of information about Transifex</h3><p><strong>Transifex</strong> is a Localization Automation Platform that helps developers and marketers publish digital content across multiple languages.</p><p>It has a substantial number of features:</p><ul><li>File &amp; content hosting. Keep all translations in one centralized platform.</li><li>Team management &amp; collaboration. There are 6 user roles in Transifex.</li><li>Powerful and easy solution for Content Operations.</li><li>Notification system: Email notifications, In-app notifications, Watch notifications, Webhooks, Slack integration.</li><li>Detailed insights &amp; reporting.</li><li>HTML and variable placeholders.</li><li>Working with Plurals and Genders translations.</li><li>Translation Memory to allow consistency of strings between the different platform projects.</li><li>Many supported files formats, including YAML, XHTML, XLIFF, PO, STRINGS, and PLIST.</li></ul><p>Transifex has 6 user roles:</p><ul><li>Organization Administrator</li><li>Project Maintainers</li><li>Team Manager</li><li>Language Coordinator</li><li>Reviewers</li><li>Translator</li></ul><h3>Transifex’s Version Control</h3><p>The biggest downside of Transifex that affects all platforms is the missing version control of localizations. Imagine you released a version that has a translation with some unique key. In the next version, you realize that key became useless and you think of removing it. Because of missing version control, the removal of the key will affect all previous app versions because the app relies on the downloaded translations as the source of truth. So when the app will use <strong>NSLocalizedString(“that_removed_key”)</strong> you will most probably get an empty string. In order to support the previous versions and to move forward with key deprecations we move the old, unused keys under a new section in the <strong>.strings</strong> file:</p><pre>// MARK: - Deprecated</pre><pre>&quot;deprecated_key&quot; = &quot;translated_string&quot;;</pre><p>And for each version bump we move unused keys under the previous version section:</p><pre>// MARK: - 4.0.0</pre><pre>&quot;deprecated_key_in_4.0.1&quot; = &quot;translated_string&quot;;</pre><h3><strong>Crunchyroll iOS localizations upload/download flow</strong></h3><p>The flow is the following:</p><ol><li>The product owner elaborates a new feature, which probably contains some text (button, label, etc.) in English.</li><li>Dev team, as a part of the development process, adds the provided text to locale files, defines new translation keys. When the PR passes the validation, the locale files get merged to the <strong>main</strong> branch.</li><li>When a new PR is merged to <strong>main</strong>, GitHub will trigger a Jenkins job responsible for uploading translations into the iOS Transifex project.</li><li>The uploader Jenkins job checkouts to the project’s <strong>main</strong> branch and uploads the locale files to Transifex using <a href="https://docs.transifex.com/client/introduction">Transifex CLI</a>.</li><li>The team of translators will translate, and review the strings.</li><li>Transifex triggers the following webhooks:</li></ol><ul><li><strong>Translation completed</strong>— it’s fired whenever a new translation is added and triggers a Jenkins job which is responsible for retrieving the strings from Transifex and uploading them to the staging S3 bucket.</li><li><strong>Review completed</strong> — it’s fired whenever a translation gets approved and triggers the deployment of the reviewed strings to the production S3 bucket.</li></ul><p>7. When locale files and their translations will reach the S3 bucket, clients will be able to download them using the S3 bucket URL.</p><figure><img alt="S3 bucket for the production Crunchyroll iOS localizations" src="https://cdn-images-1.medium.com/max/757/1*Q-7oWVlxApcZK-WeLivyng.png" /><figcaption>S3 bucket for the production Crunchyroll iOS localizations</figcaption></figure><figure><img alt="Inside of a lproj folder" src="https://cdn-images-1.medium.com/max/800/1*fxQWFiw_N62UY_UGZpqNKg.png" /><figcaption>Inside of a lproj folder</figcaption></figure><p>Each locale is stored in a <strong>.lproj</strong> folder that contains:</p><ul><li><strong>InfoPlist.strings</strong> — localizations for strings from <strong>Info.plist</strong> file.</li><li><strong>Localizable.strings </strong>— singular localizations.</li><li><strong>Localizable.stringdict</strong> — plural localizations.</li></ul><p>Before releasing a new version we bundle the translations in the case when the Crunchyroll iOS app will not have a network connection. We are using Transifex CLI to download them as <strong>.strings</strong>,<strong> .stringsdict</strong> files, and then bundle them as resource files. The <strong>InfoPlist.strings</strong> file is copied into the main bundle because you can’t reference it at runtime.</p><h3>Consuming strings at runtime</h3><p>On each app startup, we download the localization files for the current preferred locale. As <strong>InfoPlist.strings</strong> is not needed at runtime, we use only the <strong>Localizable.{strings, stringsdict}</strong> files. We save them in a <strong>{locale}.lproj</strong> folder within a <strong>Translations.bundle</strong> that acts like a folder.</p><figure><img alt="Inside of Crunchyroll iOS app documents folder" src="https://cdn-images-1.medium.com/max/674/1*iHbbiW6BvAIZYyOclxxWgw.png" /><figcaption>Inside of Crunchyroll iOS app documents folder</figcaption></figure><p>After the localizations are downloaded we now can use the <a href="https://developer.apple.com/documentation/foundation/1418095-nslocalizedstring"><strong>NSLocalizedString</strong></a><strong> </strong>function to get the translation.</p><pre>public func <strong>NSLocalizedString</strong>(<br>    _ key: String,<br>    tableName: String? = nil,<br>    bundle: Bundle = Bundle.main,<br>    value: String = &quot;&quot;,<br>    comment: String<br>) -&gt; String</pre><p>As these localizations are not in the main bundle, we can’t use that function with the default parameters. We shall create a new <strong>Bundle</strong> instance with the <strong>Translations.bundle + {locale}.lproj </strong>URL<strong> </strong>—the<strong> </strong>local folder created in the app’s Documents folder, and then pass the bundle instance to the <strong>NSLocalizedString </strong>as<strong> </strong>a parameter<strong>. </strong>We also shall pass the <strong>tableName</strong> parameter, and for our case it’s <strong>Localizable</strong>.</p><h3>Conclusion</h3><p>We were able to scale the Transifex across many projects Web, iOS, Android, and LRX. We’ve been using it for more than 2 years in production and we are happy with the choice we made.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6dee0c4afdd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crunchyroll/crunchyroll-ios-i18n-f6dee0c4afdd">Crunchyroll iOS i18n</a> was originally published in <a href="https://medium.com/crunchyroll">Crunchyroll</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>