<?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 Sushruth S on Medium]]></title>
        <description><![CDATA[Stories by Sushruth S on Medium]]></description>
        <link>https://medium.com/@sushruth.s17?source=rss-368ee12059e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nBg37fAaN1lecKnJctwybw.jpeg</url>
            <title>Stories by Sushruth S on Medium</title>
            <link>https://medium.com/@sushruth.s17?source=rss-368ee12059e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:52:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sushruth.s17/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[let it run…]]></title>
            <link>https://medium.com/@sushruth.s17/let-it-run-f51f6c06400d?source=rss-368ee12059e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f51f6c06400d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[jetbrains]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Sushruth S]]></dc:creator>
            <pubDate>Fri, 21 Jun 2024 21:17:09 GMT</pubDate>
            <atom:updated>2024-06-21T21:25:12.087Z</atom:updated>
            <content:encoded><![CDATA[<h3>let it run: The Battle of Kotlin’s .let vs .run</h3><p>Exploring two of Kotlin’s coolest scope functions: .let and .run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*6KhP7EdmLgP76zDcsYyr7w.gif" /></figure><h4>Why let them run? What Are They?</h4><p>.let is like a Post-it note reminding you to do something specific with an object.</p><pre>val name = &quot;Kotlin&quot;<br>val length = name?.let {<br>    println(&quot;The name is $it&quot;)<br>    it.length<br>}</pre><p>.run is like a checklist that helps you organize and complete multiple tasks in one go.</p><pre>val length = &quot;Hello&quot;.run {<br>    println(&quot;The greeting is $this&quot;)<br>    this.length<br>}</pre><h4>When to Use .let?</h4><ul><li><strong>Null Safety:</strong> When you want to execute code only if an object is not null.</li><li><strong>Non-nullable Result:</strong> When you want to perform multiple operations and return a non-nullable result.</li></ul><h4>When to Use .run?</h4><ul><li><strong>Initialization:</strong> When you want to initialize an object and immediately call methods on it.</li><li><strong>Object Configuration:</strong> When you want to configure an object and return the result.</li></ul><h4>The Differences: Scope of it and this</h4><ul><li><strong>.let:</strong> Inside the block, the object is referenced by it</li><li><strong>.run:</strong> Inside the block, the object is referenced by this</li><li>.let takes the object as an argument while .run takes the object as the context</li></ul><h4>Conclusion: let them run</h4><ul><li>Use .let for null safety and scoped variables.</li><li>Use .run for initialization and configuration.</li></ul><p>Now go ahead and <strong>let</strong> them <strong>run</strong> in your code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f51f6c06400d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Destructuring: Kotlin ✨]]></title>
            <link>https://medium.com/@sushruth.s17/the-art-of-destructuring-kotlin-ab30d6055bac?source=rss-368ee12059e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab30d6055bac</guid>
            <category><![CDATA[jetbrains]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Sushruth S]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 10:04:47 GMT</pubDate>
            <atom:updated>2024-04-14T10:10:06.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rL4R84jSrGL79qSqekNRYg.jpeg" /></figure><p>Imagine a grand celebration where unwrapping gifts isn’t just about opening boxes but unleashing a wave of joy and surprises. That’s exactly what Kotlin’s destructuring does — it turns data handling into a cheerful dance, filled with wit and charm.</p><h4>Unwrapping in style 🧞</h4><p>In Kotlin, we don’t just fetch data; we unravel it with style. Take this snippet, for instance:</p><pre>// magicianSupplies is list of String with size &gt;= 3<br>val magicianSupplies = listOf(&quot;Top hat&quot;, &quot;Magic wand&quot;, &quot;White rabbit&quot;)<br>val (magicHat, magicWand, rabbit) = magicianSupplies<br>println(&quot;magicHat: $magicHat&quot;) // Output: magicHat: Top hat<br>println(&quot;magicWand: $magicWand&quot;) // Output: magicWand: Magic wand<br>println(&quot;rabbit: $rabbit&quot;) // Output: rabbit: White rabbit</pre><p>In a single line, we’ve not only fetched the magician’s tools but also set the stage for a magical performance.</p><h4>A Twist in the Tale 🔮</h4><p>Now, let’s talk functions. Picture a function that brings not one but two surprises. Instead of dealing with them separately, Kotlin lets us do this:</p><pre>fun surpriseParty(): Pair&lt;String, Int&gt; {<br>    return Pair(&quot;Cake&quot;, 42)<br>}<br><br>val (partyTheme, guestCount) = surpriseParty()<br>println(&quot;Welcome to the $partyTheme-themed party with $guestCount guests!&quot;)</pre><p>It’s like throwing a surprise party for your code and watching it light up with joy.</p><h4>Journey into the Data Wonderland 🚀</h4><p>But hold on, there’s more to this adventure! Kotlin’s destructuring isn’t just about pairs; it’s a thrilling journey into the depths of data structures. Let’s embark on a quest with a treasure map:</p><pre>val treasureMap = mapOf(<br>    &quot;X&quot; to &quot;Gold coins&quot;,<br>    &quot;Y&quot; to &quot;Diamonds&quot;,<br>    &quot;Z&quot; to &quot;Chocolate bars (because why not?)&quot;<br>)<br><br>for ((location, loot) in treasureMap) {<br>    println(&quot;Ahoy, mate! We found $loot at $location!&quot;)<br>}</pre><p>Destructuring transforms ordinary loops into exciting escapades.</p><h4>Signing Off with a Sparkle 🪄</h4><p>And there you have it, Destructuring in Kotlin isn’t just about efficiency; it’s about adding a sprinkle of magic, and a whole lot of charm to your code. So go ahead, embrace the whimsy, and may your coding adventures be as delightful as a surprise box of laughter!</p><p><em>Disclaimer: No rabbits were pulled out of hats during the creation of this blog post. Kotlin, however, may cause unexpected bursts of joy.</em></p><blockquote>Reference: <a href="https://kotlinlang.org/docs/destructuring-declarations.html">https://kotlinlang.org/docs/destructuring-declarations.html</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab30d6055bac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin: The Superhero of Boring Code]]></title>
            <link>https://medium.com/@sushruth.s17/kotlin-the-superhero-of-boring-code-4cfe211ed07d?source=rss-368ee12059e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cfe211ed07d</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Sushruth S]]></dc:creator>
            <pubDate>Sat, 22 Apr 2023 09:16:26 GMT</pubDate>
            <atom:updated>2023-04-22T09:16:26.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*SqLpKR54o18-onBe0JQGIg.png" /></figure><p>Are you tired of writing the same boilerplate code over and over again? Do you dream of a world where coding is fun and exciting? Well, my friend, you’re in luck! Enter Kotlin, the superhero of boring code.</p><p>Kotlin is a modern programming language that runs on the Java Virtual Machine. It was designed to address the shortcomings of Java and provide a more concise and readable syntax. Kotlin is not only easy to learn, but it also provides many features that are not commonly used but can greatly reduce boilerplate code and increase efficiency.</p><p>Let’s dive into some of Kotlin’s superpowers:<br><strong>1. Null Safety:</strong> Do you hate NullPointerExceptions? Me too! Kotlin’s null safety feature ensures that you handle null values explicitly, reducing the likelihood of runtime errors. Here’s an example:</p><pre>fun printLength(str: String?) {<br>    println(str?.length ?: 0)<br>}</pre><p>In this example, we use the <em>safe call operator</em> ?. and the <em>Elvis operator</em> ?: to handle null values. If str is null, we print 0 instead of crashing our application. Hooray for null safety!</p><p><strong>2. Extension Functions:</strong> Do you want to add some spice to your classes? Extension functions allow you to add functionality to existing classes without having to inherit from them. Here’s an example:</p><pre>fun String.reverse(): String {<br>    return this.reversed()<br>}</pre><p>In this example, we define an extension function reverse() for the String class. We can call this function on any string and get its reverse. Who knew adding functionality could be so easy?</p><p><strong>3. Lambdas:</strong> Do you like to pass functions as arguments? Lambdas allow you to do just that, making your code more flexible and expressive. Here’s an example:</p><pre>val numbers = listOf(1, 2, 3, 4, 5)<br>val evenNumbers = numbers.filter { it % 2 == 0 }</pre><p>In this example, we use a lambda expression to filter even numbers from a list of integers. The lambda expression { it % 2 == 0 } takes an integer argument and returns a boolean value. Who needs named functions when you can have anonymous ones?</p><p><strong>4. String Templates:</strong> Do you like to concatenate strings? String templates allow you to interpolate variables directly into a string, making your code more readable and concise. Here’s an example:</p><pre>val name = &quot;John&quot;<br>val age = 30<br>val message = &quot;My name is $name and I am $age years old.&quot;<br>println(message)</pre><p>In this example, we use string templates to interpolate variables into a string. We use the dollar sign $ to indicate that we want to interpolate a variable. Who needs the plus sign + when you can have dollar signs?</p><p><strong>5. Object Declarations:</strong> Do you want to create a global object? Object declarations allow you to do just that, without having to create a class. Here’s an example:</p><pre>object Global {<br>    fun sayHello() {<br>        println(&quot;Hello, world!&quot;)<br>    }<br>}<br><br>fun main() {<br>    Global.sayHello()<br>}</pre><p>In this example, we create an object Global that has a function sayHello(). We can call this function anywhere in our application without creating an instance of the object. Who needs classes when you can have objects?</p><p><strong>6. Companion Objects:</strong> Do you want to define static members and functions for a class? Companion objects allow you to do just that, without having to use the static keyword. Here&#39;s an example:</p><pre>class Person(val name: String) {<br>    companion object {<br>        fun fromJson(json: String): Person {<br>            // parse JSON and return a Person object<br>        }<br>    }<br>}<br><br>fun main() {<br>    val json = &quot;{\&quot;name\&quot;: \&quot;John\&quot;}&quot;<br>    val person = Person.fromJson(json)<br>    println(person.name)<br>}</pre><p>In this example, we define a companion object for the Person class that has a function fromJson() that parses JSON and returns a Person</p><p><strong>7. Data Classes:</strong> Do you like to create classes with lots of properties? Data classes allow you to create classes with lots of properties without having to write a lot of boilerplate code. Here’s an example:</p><pre>data class Person(val name: String, val age: Int)</pre><p>In this example, we create a Person class with two properties: name and age. The data keyword generates a lot of useful methods for us, such as equals(), hashCode(), and toString(). Who needs to write all those methods when you can just use data?</p><p><strong>8. Elvis Operator:</strong> Do you like to handle null values explicitly? The Elvis operator allows you to do just that, in a fun and playful way. Here’s an example:</p><pre>val name: String? = null<br>val result = name ?: &quot;unknown&quot;<br>println(result)</pre><p>In this example, we use the Elvis operator ?: to handle a null value. If name is null, we print &quot;unknown&quot; instead of crashing our application. Who needs a boring ternary operator when you can have an Elvis?</p><p><strong>9. Function Types:</strong> Do you like to pass functions as arguments? Function types allow you to do just that, in a way that is both powerful and expressive. Here’s an example:</p><pre>fun calculate(a: Int, b: Int, operation: (Int, Int) -&gt; Int): Int {<br>    return operation(a, b)<br>}<br><br>val sum = calculate(1, 2) { a, b -&gt; a + b }<br>val product = calculate(3, 4) { a, b -&gt; a * b }</pre><p>In this example, we define a calculate() function that takes two integers and a function that takes two integers and returns an integer. We can pass different functions to calculate() to perform different operations, such as addition or multiplication. Who needs to write separate functions for each operation when you can just pass a function as an argument?</p><p>With these superpowers, Kotlin can transform your boring code into exciting and readable code. You’ll be a coding superhero in no time!</p><p>In conclusion, if you’re tired of writing the same boring code over and over again, give Kotlin a try. With its many features, Kotlin can greatly reduce boilerplate code and increase efficiency. Who knows, you might even enjoy coding again!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cfe211ed07d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSV to XML — For Android Projects]]></title>
            <link>https://medium.com/@sushruth.s17/csv-to-xml-for-android-projects-1384573ba2b0?source=rss-368ee12059e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1384573ba2b0</guid>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[csv]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[csvtoxml]]></category>
            <category><![CDATA[android-studio]]></category>
            <dc:creator><![CDATA[Sushruth S]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 07:47:23 GMT</pubDate>
            <atom:updated>2023-03-16T07:47:23.490Z</atom:updated>
            <content:encoded><![CDATA[<h3>CSV to XML — For Android Projects</h3><p>If you’re here you might have already read the previous blog on how to convert XML to CSV, if not here’s the link for you.</p><p><a href="https://medium.com/@sushruth.s17/xml-to-csv-for-android-projects-7745cffc1263">XML to CSV— For Android Projects</a></p><p>After demonstrating how to convert XML to CSV using Python in our previous blog, you may still find yourself struggling to incorporate these changes back into the original XML files.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F17296473&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fvicky-kaushal-masaan-dukh-sad-sad-vicky-kaushal-gif-17296473&amp;image=https%3A%2F%2Fmedia.tenor.com%2FQOkWoZH3PbIAAAAC%2Fvicky-kaushal-masaan.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5aa59cd84d2e3048f18154e37f59e0e/href">https://medium.com/media/f5aa59cd84d2e3048f18154e37f59e0e/href</a></iframe><p>We got you, let’s now delve into the process of converting CSV files back into XML using Python.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16048282&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fhrithik-hrithik-roshan-hr-superstar-hrithik-dance-gif-16048282&amp;image=https%3A%2F%2Fmedia.tenor.com%2FClBpRC77UpoAAAAM%2Fhrithik-hrithik-roshan.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/38da5b39d87456aaed8fbc947b67f9e5/href">https://medium.com/media/38da5b39d87456aaed8fbc947b67f9e5/href</a></iframe><h3>Introduction</h3><p>Let&#39;s have a little introduction if you are new here. Localization is a crucial aspect of developing a mobile app that caters to a wide audience. If your app supports multiple languages, you need to provide language-specific resources for each supported language. Android provides a way to manage these resources using the strings.xml file, which is an XML file that contains a set of string resources for a specific locale. In this article, we&#39;ll explore how to convert a CSV file with strings to multiple strings.xml files based on language columns.</p><h3>Solution</h3><p>Digging into the solution directly, We can use Python to convert a CSV file with strings to multiple strings.xml files based on language columns</p><ol><li>We first need to read the CSV file and extract the language codes from the header row. The language codes are the names of the language columns, such as en for English or kn for Kannada and so on.</li><li>For each language code, we create a new strings.xml file and write the XML header and opening &lt;resources&gt; tag. (You can skip this if you don’t need header and resource tags)</li><li>We then loop through each row of the CSV file and extract the value of the string for each language code. We write each string to the corresponding strings.xml file in the format &lt;string name=&quot;string_name&quot;&gt;string_value&lt;/string&gt;, where string_name is the value of the first column of the CSV file, and string_value is the value of the corresponding language column.</li><li>After looping through all the rows of the CSV file, we close the &lt;resources&gt; tag of each strings.xml file.</li></ol><p><strong>Ignoring Empty Columns</strong></p><p>In some cases, some language columns may be empty. We can modify the above code to ignore empty columns while converting to &lt;string&gt; tags. We can add an if statement that checks if the value of the language column is empty before writing to the corresponding strings.xml file.</p><p>Here is a sample CSV file that we are using to convert it to XML file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*6bwU8pShfhF8zP69eqnkVw.png" /><figcaption>output.csv</figcaption></figure><p>Here’s a full Python script:</p><pre>import csv</pre><pre>def convertCsvToXmls():<br>    # Specify the name of the CSV file<br>    csv_file = &#39;output.csv&#39;<br><br>    # Open the CSV file for reading<br>    with open(csv_file, newline=&#39;&#39;) as csvfile:<br>        reader = csv.reader(csvfile, delimiter=&#39;,&#39;)<br><br>        # Get the header row to extract the language codes<br>        header_row = next(reader)<br>        language_codes = header_row[1:]<br><br>        # Loop through each language code and create a new strings.xml file<br>        for lang_code in language_codes:<br>            # Create a new file for the current language code<br>            file_name = f&#39;strings_translated_{lang_code}.xml&#39;<br>            with open(file_name, &#39;w&#39;, encoding=&#39;utf-8&#39;) as f:<br>                # Write the XML header and opening &lt;resources&gt; tag<br>                f.write(&#39;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&#39;)<br>                f.write(&#39;&lt;resources&gt;\n&#39;)<br><br>                # Loop through each row of the CSV file and write the strings to the file<br>                csvfile.seek(0)  # reset file pointer to beginning of file<br>                next(reader)  # skip header row<br>                for row in reader:<br>                    string_name = row[0]  # first column of CSV file<br>                    string_value = row[language_codes.index(lang_code) + 1]  # corresponding language column<br>                    if string_value.strip():  # check if value is not empty<br>                        f.write(f&#39;&lt;string name=&quot;{string_name}&quot;&gt;{string_value}&lt;/string&gt;\n&#39;)<br><br>                # Close the &lt;resources&gt; tag<br>                f.write(&#39;&lt;/resources&gt;\n&#39;)</pre><pre>if __name__ == &#39;__main__&#39;:<br>    convertCsvToXmls()</pre><p>There will be 4 output XML files generated here named <br>strings_translated_en.xml , strings_translated_kn.xml , strings_translated_hi.xml &amp; strings_translated_fr.xml which will contain their respective string resources based on the values present in CSV.</p><p>That&#39;s it, now you have multiple XML files associated with their language codes, copy the content and paste it into your Android project</p><p>Now that we’ve explored both methods of converting XML to CSV and CSV to XML, we’ve achieved a balanced understanding of these processes.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25200656&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fthanos-balance-perfect-gif-25200656&amp;image=https%3A%2F%2Fmedia.tenor.com%2FvZiLS-HKM90AAAAC%2Fthanos-balance.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/81e4b0fdd0e4bd8667a823438ab9899c/href">https://medium.com/media/81e4b0fdd0e4bd8667a823438ab9899c/href</a></iframe><p>This approach saves time and effort when dealing with a large number of language-specific string resources.</p><p>We hope you found this helpful and informative. Keep an eye out for our upcoming articles, as we continue to provide valuable insights on various topics. See you soon!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F4742523&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fshah-rukh-khan-bollywood-good-bye-bye-wave-gif-4742523&amp;image=https%3A%2F%2Fmedia.tenor.com%2FeqRWjceDCbYAAAAC%2Fshah-rukh-khan-bollywood.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/f4844023aff600cc5aae2836a842b59a/href">https://medium.com/media/f4844023aff600cc5aae2836a842b59a/href</a></iframe><p>If you enjoyed reading this blog post, please consider showing your appreciation by giving applaud on this post.</p><p>Follow for more updates<br><a href="https://www.linkedin.com/in/sushruth-s-857841198/">https://www.linkedin.com/in/sushruth-s-857841198/</a><br><a href="https://twitter.com/Sushruth_17">https://twitter.com/Sushruth_17</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1384573ba2b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XML to CSV— For Android Projects]]></title>
            <link>https://medium.com/@sushruth.s17/xml-to-csv-for-android-projects-7745cffc1263?source=rss-368ee12059e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/7745cffc1263</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[csv]]></category>
            <dc:creator><![CDATA[Sushruth S]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 10:30:38 GMT</pubDate>
            <atom:updated>2023-03-16T09:56:50.205Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>As software developers and localization teams work to expand the reach of their products to global audiences, it becomes increasingly important to manage and merge string translations from multiple sources. If you work on a multilingual project, you may be dealing with multiple XML files that contain translations for your application.</p><blockquote>I know the difficulties faced in copying the strings, removing &lt;string&gt; tags and translating the strings, and again adding &lt;string&gt; tags to the translated strings.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F22727638&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fakshay-kumar-de-dana-dan-akshay-cry-akshay-crying-crying-gif-22727638&amp;image=https%3A%2F%2Fmedia.tenor.com%2FIlpDflxljGYAAAAC%2Fakshay-kumar-de-dana-dan.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6e83039931f7fa944c1f281d0ba8e61/href">https://medium.com/media/e6e83039931f7fa944c1f281d0ba8e61/href</a></iframe><p>To ensure that all translations are complete, you may want to combine all these files into a single sheet and filter out any keys that are missing translations. In this blog post, we’ll explore how to achieve this using Python to parse and manipulate XML files containing the string translations, and then export them to a universal CSV file format. This post will explore a Python script that can merge and filter string translations from multiple XML files into a single CSV file.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16994809&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fakshay-kumar-meme-bollywood-bhagam-bhag-gif-16994809&amp;image=https%3A%2F%2Fmedia.tenor.com%2F0hAr-Z-W_7AAAAAC%2Fakshay-kumar-meme.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cdb0fd39e91fbb43d25b61230b5c84d/href">https://medium.com/media/7cdb0fd39e91fbb43d25b61230b5c84d/href</a></iframe><h3>The Problem</h3><p>You know the problem now and will not explain it again, rather let&#39;s look into the possible ways to solve it. Your goal is to merge these files into a single CSV file that contains only the unique string translations and the language codes associated with them. You also want to ignore any string tags with translatable=&quot;false&quot;, as these tags will not need to be translated</p><h3>The Solution</h3><p>To solve this problem, we can use Python and its built-in xml.etree.ElementTree library to parse the XML files and extract the relevant string translations. We&#39;ll also use the csv module to write the output to a CSV file.</p><p>Before going to Python, We know that all the strings files in the Android project will be named strings.xml, copy these files to your python project directory and rename the file with a format strings_[language_code].xml where [language_code] = en/kn/hi, etc. Now, the files are named as strings_en.xml, strings_kn.xml, strings_hi.xml, and strings_fr.xml, representing translations for English, Kannada, Hindi, and French, respectively.</p><p>Here&#39;s the full Python script:</p><pre>import csv<br>import os<br>import xml.etree.ElementTree as ET<br>from collections import defaultdict</pre><pre>def filterAndConvertToCsv():<br>    # list of input file paths<br>    input_files = [&#39;strings_en.xml&#39;, &#39;strings_kn.xml&#39;, &#39;strings_hi.xml&#39;, &#39;strings_fr.xml&#39;]<br><br>    # output file path for CSV file<br>    output_file = &#39;output.csv&#39;<br><br>    # create a dictionary to store the translations for each key<br>    key_to_translations = defaultdict(dict)<br><br>    # iterate over the input files<br>    for input_file in input_files:<br>        # parse the XML file<br>        tree = ET.parse(input_file)<br>        root = tree.getroot()<br><br>        # extract the language code from the file name<br>        lang_code = os.path.splitext(os.path.basename(input_file))[0].split(&#39;_&#39;)[1]<br><br>        # iterate over the &lt;string&gt; tags and extract the key-value pairs<br>        for string in root.iter(&#39;string&#39;):<br>            key = string.attrib[&#39;name&#39;]<br>            value = string.text<br><br>            # only add the key-value pair if the value is not empty<br>            if value:<br>                value = value.strip()<br><br>                # ignore the key-value pair if the tag is not translatable<br>                translatable = string.attrib.get(&#39;translatable&#39;)<br>                if translatable is not None and translatable.lower() == &#39;false&#39;:<br>                    continue<br><br>                key_to_translations[key][lang_code] = value<br><br>    # create a list to store the unique translations for each key<br>    unique_translations = []<br><br>    # iterate over the keys and translations<br>    for key, translations in key_to_translations.items():<br>        # only add the key to the list if it appears in only one file<br>        if len(translations) == 1:<br>            unique_translations.append((key, translations))<br><br>    # write the unique translations to a CSV file<br>    with open(output_file, &#39;w&#39;, newline=&#39;&#39;, encoding=&#39;utf-8&#39;) as file:<br>        writer = csv.writer(file)<br><br>        # write the header row<br>        header_row = [&#39;string_name&#39;]<br>        for input_file in input_files:<br>            lang_code = os.path.splitext(os.path.basename(input_file))[0].split(&#39;_&#39;)[1]<br>            header_row.append(lang_code)<br>        writer.writerow(header_row)<br><br>        # write the data rows<br>        for key, translations in unique_translations:<br>            data_row = [key]<br>            for input_file in input_files:<br>                lang_code = os.path.splitext(os.path.basename(input_file))[0].split(&#39;_&#39;)[1]<br>                data_row.append(translations.get(lang_code, &#39;&#39;))<br>            writer.writerow(data_row)   </pre><pre>if __name__ == &#39;__main__&#39;:<br>    filterAndConvertToCsv()</pre><p>The output CSV file will be generated in the same directory of your py file <br>Use that CSV file to update your translations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*t9VhEDcs_oH19psC1H7HfA.png" /><figcaption>Sample generated CSV where all XML files had their unique keys</figcaption></figure><p><strong>Points to remember : </strong><br>1. Use this file name format strings_[language_code].xml so that the CSV file created will contain language codes as column headers<br>2. Files should be present in the same directory as this py file<br>3. If any new XML files are added, update the input_files list in the code<br>4. Make sure files defined in the input_files list are present in the directory<br>5. In your Android project while creating a string in XML make sure to create it only in the default strings.xml so that the keys are considered unique keys in the above python script</p><p>That&#39;s it, You have now successfully converted XML files to CSV. Now you have a CSV file with only strings that require translations</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FTfvtOoazWFxmLpgwFg%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FTfvtOoazWFxmLpgwFg%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FTfvtOoazWFxmLpgwFg%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbe6faa659b4d745478e6c0d40c02fa5/href">https://medium.com/media/fbe6faa659b4d745478e6c0d40c02fa5/href</a></iframe><blockquote>Now that you have completed translations in CSV, you might be looking for a way to convert CSV back to XML.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*jv7h36cXCo6cln2CNA47sA.png" /></figure><p>Yes, even that is covered in the below blog -</p><p><a href="https://medium.com/@sushruth.s17/csv-to-xml-for-android-projects-1384573ba2b0">CSV to XML — For Android Projects</a></p><p>Keep following for more updates, Cheers !!</p><p><a href="https://www.linkedin.com/in/sushruth-s-857841198/">https://www.linkedin.com/in/sushruth-s-857841198/</a><br><a href="https://twitter.com/Sushruth_17">https://twitter.com/Sushruth_17</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7745cffc1263" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Management Examinations]]></title>
            <link>https://medium.com/@sushruth.s17/management-examinations-59e9dfc1bb8a?source=rss-368ee12059e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/59e9dfc1bb8a</guid>
            <category><![CDATA[youth4work]]></category>
            <dc:creator><![CDATA[Sushruth S]]></dc:creator>
            <pubDate>Wed, 18 Apr 2018 07:31:26 GMT</pubDate>
            <atom:updated>2018-04-18T07:31:26.209Z</atom:updated>
            <content:encoded><![CDATA[<p>Here’s our top exam writing tips to help you understand how to answer exam questions:</p><p>1. Practice Past Papers</p><p>There really is no better way to get exam ready than by attempting past papers. Most exam bodies should have past papers available online but your teacher will get you started on these in class.</p><p>This process isn’t just about preparing an answer for a specific question, it’s about understanding how you approach a question in an exam, how to structure your answer, the timings you should assign and what information will get marks.</p><p>2. Read All Questions Carefully</p><p>The stress of the situation can cause you to misread a question, plan your answer out, start writing your response and then realise you made a mistake and wasted vital time. Even though you generally won’t be writing answers to every question on the paper, reading all questions thoroughly will ensure you make the right choices and can highlight how much you know about the topic.</p><p>Don’t forget to attempt all questions that you have selected. However, be careful of MCQ questions with negative marking. If you’re not sure of the answer you could cost yourself some valuable marks.</p><p>3. Manage Your Time</p><p>This is where you need to be strict on yourself. Once you have assigned a time limit for each question, you MUST move on once you hit it or you won’t be able to give the next question your full attention.</p><p>Remember to leave yourself some time at the end to go back over your answers and add in little notes or pieces of information about the topic. You never know, this could help bump you up a grade!</p><p>4. Structure Your Answer</p><p>Don’t just jump into writing your answer. Take the first few minutes to <a href="http://www.lifehack.org/articles/communication/7-tips-for-writing-exam-essays.html">plan the structure of your essay</a>which will save you time when you are delving into meaty parts. Always stay on topic; if you’re discussing the role of women in society as portrayed by the author in <a href="https://www.goconqr.com/en/p/605657-gcse-english-literature--of-mice-and-men-notes">Of Mice and Men</a>, don’t digress and start outlining other themes in the book for example.</p><p>Most essays should have an introduction, three main points and a conclusion. A lot of students see a conclusion as a final sentence to finish the piece off. A strong conclusion give an A grade student the chance to shine by bringing everything together and fortifying their opinion.</p><p>5. Explore Both Sides of an Argument</p><p>Building your argument in the main body of your exam answer will give your overall opinion credibility. English language questions, for example, encourage you to explore both sides of an argument and then conclude with a critical analysis of your answer.</p><p>Many questions you approach will look as though they seek a straightforward answer but in reality they want you to fully outline a structured essay. Don’t fall into the trap of providing a one-sided view, get your hands dirty and open your mind to other possibilities.</p><p>6. Review Your Answers Thoroughly</p><p><a href="https://www.goconqr.com/en/examtime/blog/good-habits-for-students/">Smart students</a> can still make the mistake of handing their answer book in without checking through what they have written. Proofread your answers as much as you can to correct any spelling mistakes and add any extra comments you think are worth mentioning.</p><p>You will be surprised what you can spot in those last few minutes. This is your last chance to throw in that quotation, list other relevant points or even draw a quick diagram. Now is not the time to drop your game, show the examiner what you’re made of!</p><p>Remember, the exams are not designed to trick you. Don’t panic on the day of your exam or this brain freeze could mean that you get a lower grade that you truly deserve. Convince yourself that you know how to answer exam questions and your almost there.</p><h3>About Youth4work</h3><p>Youth4work.com is a ‘People Platform’ which empowers youth to assess themselves, improve their talents and showcase themselves for their talents and professional achievement.</p><p>We call what we are building ‘Human Tech’ which gathers intelligence and deep insights on each and every member of Youth4work.</p><p>The core belief is that each individual is unique and always goes through a Journey of</p><ol><li>Identifying his/her true Talents</li></ol><p>With a Billion people across the world &amp; probably a million of chrecter sets / skills that make each person unique vis-a-vis the other. Youth4work assists each individual to tests themselves and find their own unique strengths &amp; weakness and build their own talents map and understand their own psychological strengths.</p><p>2. Improve Themselves</p><p>Youth4work empowers each individual to become a part of a community of like talented individuals and enables them to share and learn from each other. The ‘Human tech’ suggests the right education personalized for each individual to help them grow more professionally in the area of their real interests and true talents.</p><p>3. Showcase themselves</p><p>With almost a Million Youth who have assessed themselves and built their assessed professional profiles their are a billion data points on for individuals, skills and market that enables the ‘human tech’ to compare each individual to millions of others and help showcase them for their respective talents &amp; strengths for the right opportunity.</p><p>Youth4work impacts professional human lives from the very foundation. We aid young generation right from their college, in their education &amp; preparation and eventual career journey and personal professional growth. Youth4work believes in building a Transparent Platform, a marketplace for true talent which is more than a business for us. We have made an impact on thousands of lives and driven to positively impact millions more.</p><ol><li>Test Link: <a href="https://www.google.com/url?q=https%3A%2F%2Fwww.prep.youth4work.com%2FManagement%2FCAT-Test&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNG7PCmBsIpaLB1ePWX3yfNLqnx9NA">https://www.prep.youth4work.com/Management/CAT-Test</a></li><li>App Link: <a href="https://play.google.com/store/apps/details?id=com.youth4work.CAT">https://play.google.com/store/apps/details?id=com.youth4work.CAT</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59e9dfc1bb8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>