Re: Upstream docbook issues
"Jamenson Espindula" ([email protected] via blfs-dev Mailing List) <[email protected]> Sat, 3 Jan 2026 16:13:02 -0300
| Newsgroups | gmane.linux.lfs.beyond.devel |
|---|---|
| Message-ID | <CAOW_YOmjBxMq28GYsrdNJ3LaD9F5qVStt-CU_NV8v10vgwmdKw@mail.gmail.com> |
Em sáb., 3 de jan. de 2026 às 12:58, Bruce Dubbs <[email protected]> escreveu: > > The totals are actually calculated in stylesheets/lfs-xsl/common.xsl. See the > templates returnvalue and calculation at the bottom of the file. > > I suggest not changing the commas and dots in the file sizes in Chapter 3 before > generating the html version of the Brazilian Portuguese book and then using a sed to > change the html files that are generated. > > Note that all the file sizes are specified in packages.ent and patches.ent in KB > where K=1024. The thousands separator are commas. In patches.ent, if the file size > is is less than 10 KB, then a dot is used to specify the size (e.g. x.y). There are > no commas in the patch sizes because the largest size there is 128 KB. > I got it. As an informative and, maybe, a suggestion, below is what Gemini said: <xsl:template name="calculation"> <xsl:param name="scope"/> <xsl:param name="total" select="0"/> <xsl:param name="position" select="1"/> <xsl:param name="locale" select="'pt'"/> <xsl:variable name="tokens" select="count($scope/varlistentry)"/> <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/> <xsl:variable name="size" select="substring-before($token,' KB')"/> <xsl:variable name="rawsize"> <xsl:choose> <xsl:when test="contains($size,',') and contains($size,'.')"> <xsl:value-of select="translate($size, '.,', '')"/> </xsl:when> <xsl:when test="contains($size,',')"> <xsl:value-of select="translate($size, ',', '')"/> </xsl:when> <xsl:when test="contains($size,'.')"> <xsl:value-of select="translate($size, '.', '')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$size"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="$position <= $tokens"> <xsl:call-template name="calculation"> <xsl:with-param name="scope" select="$scope"/> <xsl:with-param name="position" select="$position + 1"/> <xsl:with-param name="total" select="$total + $rawsize"/> <xsl:with-param name="locale" select="$locale"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$locale = 'pt'"> <xsl:choose> <xsl:when test="$total < 1000"> <xsl:value-of select="format-number($total, '#')"/> <xsl:text> KB</xsl:text> </xsl:when> <xsl:when test="$total < 1000000"> <xsl:value-of select="format-number($total, '#.###')"/> <xsl:text> KB</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="format-number($total div 1024, '#,00')"/> <xsl:text> MB</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="$locale = 'en'"> <xsl:choose> <xsl:when test="$total < 1000"> <xsl:value-of select="format-number($total, '#')"/> <xsl:text> KB</xsl:text> </xsl:when> <xsl:when test="$total < 1000000"> <xsl:value-of select="format-number($total, '#,###')"/> <xsl:text> KB</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="format-number($total div 1024, '#.00')"/> <xsl:text> MB</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:when> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> The following text was generated (by Gemini) originally in Brazilian Portuguese. I ask Google Translator to translate it into English: Explanation of Changes New locale Parameter: We've added a new parameter called locale with a default value of 'pt' (Portuguese). This allows you to specify the desired language when calling the template calculation. More Robust Data Cleaning: The rawsize variable has been modified to use the translate() function. Instead of just removing the comma, it now removes both the comma and the period. This is essential because in some input formats, the separator might be a period (e.g., 1.234 KB in English), and in others a comma (e.g., 1,234 KB in Portuguese). Using translate($size, '.,', '') is a safer way to "clean" the input string, ensuring that only numeric digits remain. Conditional Formatting Logic: The otherwise logic has been restructured. Now it contains an `<xsl:choose>` that checks the value of the `locale` parameter: If `locale` is 'pt': For values below 1000, the number is printed without a separator. For values between 1000 and 999,999, `format-number($total, '#.###')` is used. The pattern `#.###` instructs XSLT to use the period (.) as the thousands separator and not to include decimal places. For values greater than or equal to 1,000,000 (or in MB), `format-number($total div 1024, '#,00')` is used. The pattern `#,00` instructs to use the comma (,) as the decimal separator, with two decimal places. If `locale` is 'en': The logic is similar, but the formatting patterns are reversed. format-number($total, '#,###') to use the comma (,) as the thousands separator. format-number($total div 1024, '#.00') to use the dot (.) as the decimal separator.The totals are actually calculated in stylesheets/lfs-xsl/common.xsl. See the returnvalue and calculation templates at the bottom of the file. I suggest not changing the commas and dots in the file sizes in Chapter 3 before generating the html version of the Brazilian Portuguese book and then using a sed to change the html files that are generated. Note that all the file sizes are specified in packages.ent and patches.ent in KB where K=1024. The thousands separator are commas. In patches.ent, if the file size is less than 10 KB, then a dot is used to specify the size (e.g. x.y). There are no commas in the patch sizes because the largest size there is 128 KB. Jamenson Espindula -- http://lists.linuxfromscratch.org/sympa/info/blfs-dev Unsubscribe: See the above information page