<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Cannot access i18n resource bundle in Controller onIn... in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaa-p/14483045#M4948731</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/16032"&gt;@deiamolina&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The i18n model is likely not available when onInit() or onBeforeRendering() runs.&lt;/P&gt;&lt;P&gt;Use the model from the Component and wait for the ResourceBundle promise:&lt;/P&gt;&lt;P&gt;onInit: async function () {&lt;BR /&gt;const oBundle = await this.getOwnerComponent()&lt;BR /&gt;.getModel("i18n")&lt;BR /&gt;.getResourceBundle();&lt;/P&gt;&lt;P&gt;const sTitle = oBundle.getText("shellBarTitle", [sTime, sDate]);&lt;/P&gt;&lt;P&gt;this.byId("_IDGenShellBar").setTitle(sTitle);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Or:&lt;/P&gt;&lt;P&gt;this.getOwnerComponent()&lt;BR /&gt;.getModel("i18n")&lt;BR /&gt;.getResourceBundle()&lt;BR /&gt;.then((oBundle) =&amp;gt; {&lt;BR /&gt;this.byId("_IDGenShellBar")&lt;BR /&gt;.setTitle(oBundle.getText("shellBarTitle", [sTime, sDate]));&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Access the i18n model through getOwnerComponent().getModel("i18n") instead of this.getView().getModel("i18n"), and handle getResourceBundle() asynchronously in newer SAPUI5 versions.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sravan&lt;/P&gt;</description>
    <pubDate>Thu, 10 Sep 2026 10:36:42 GMT</pubDate>
    <dc:creator>sravan_aleshwaram</dc:creator>
    <dc:date>2026-09-10T10:36:42Z</dc:date>
    <item>
      <title>Cannot access i18n resource bundle in Controller onInit (Model not loaded yet)</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaq-p/14482949</link>
      <description>&lt;DIV class=""&gt;Hello everyone,&lt;/DIV&gt;&lt;DIV class=""&gt;For specific architecture and UX requirements in a KPI application I am building, I need to handle certain text strings inside the Controller instead of binding them directly in the XML View.&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;However, I am facing a timing issue where the &lt;CODE&gt;i18n&lt;/CODE&gt; model is not yet loaded or available during the early controller lifecycle hooks.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;What I have tried so far:&lt;/DIV&gt;&lt;DIV class=""&gt;1.&amp;nbsp;Accessing it inside &lt;CODE&gt;onInit&lt;/CODE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;LI-CODE lang="javascript"&gt;onInit: function () {
    // This fails because the model is not ready yet
    this._oBundle = this.getView().getModel("i18n").getResourceBundle();
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Console Error: &lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getText')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;Accessing it inside &lt;CODE&gt;onBeforeRendering&lt;/CODE&gt;:&lt;/P&gt;&lt;LI-CODE lang="abap"&gt;onBeforeRendering: function () {
    this._oBundle = this.getView().getModel("i18n").getResourceBundle();
},&lt;/LI-CODE&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Console Error: Dashboard.controller.js:20 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getResourceBundle')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;How I intend to use it:&lt;/STRONG&gt;&lt;BR /&gt;Once retrieved, I need to dynamically update UI controls with parameters like this:&lt;/DIV&gt;&lt;LI-CODE lang="abap"&gt;var sTitle = this._oBundle.getText("shellBarTitle", [sTime, sDate]);
this.byId("_IDGenShellBar").setTitle(sTitle);&lt;/LI-CODE&gt;&lt;P&gt;It did not work. The title is blank&lt;BR /&gt;&lt;BR /&gt;I am sure this is a common scenario, but many older SAP Community solutions I found rely on deprecated synchronous methods&lt;/P&gt;&lt;DIV class=""&gt;or require a lot of workaround logic.&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;What is the current best practice or modern SAPUI5 reusable approach to safely access the &lt;CODE&gt;i18n&lt;/CODE&gt; resource bundle as soon as it becomes available in the lifecycle?&lt;/DIV&gt;&lt;DIV class=""&gt;Thanks a million.&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Sep 2026 09:45:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaq-p/14482949</guid>
      <dc:creator>deiamolina</dc:creator>
      <dc:date>2026-09-10T09:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot access i18n resource bundle in Controller onIn...</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaa-p/14483045#M4948731</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/16032"&gt;@deiamolina&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The i18n model is likely not available when onInit() or onBeforeRendering() runs.&lt;/P&gt;&lt;P&gt;Use the model from the Component and wait for the ResourceBundle promise:&lt;/P&gt;&lt;P&gt;onInit: async function () {&lt;BR /&gt;const oBundle = await this.getOwnerComponent()&lt;BR /&gt;.getModel("i18n")&lt;BR /&gt;.getResourceBundle();&lt;/P&gt;&lt;P&gt;const sTitle = oBundle.getText("shellBarTitle", [sTime, sDate]);&lt;/P&gt;&lt;P&gt;this.byId("_IDGenShellBar").setTitle(sTitle);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Or:&lt;/P&gt;&lt;P&gt;this.getOwnerComponent()&lt;BR /&gt;.getModel("i18n")&lt;BR /&gt;.getResourceBundle()&lt;BR /&gt;.then((oBundle) =&amp;gt; {&lt;BR /&gt;this.byId("_IDGenShellBar")&lt;BR /&gt;.setTitle(oBundle.getText("shellBarTitle", [sTime, sDate]));&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Access the i18n model through getOwnerComponent().getModel("i18n") instead of this.getView().getModel("i18n"), and handle getResourceBundle() asynchronously in newer SAPUI5 versions.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sravan&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2026 10:36:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaa-p/14483045#M4948731</guid>
      <dc:creator>sravan_aleshwaram</dc:creator>
      <dc:date>2026-09-10T10:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot access i18n resource bundle in Controller onInit (Model not loaded yet)</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaa-p/14486976#M4949002</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I need to handle certain text strings inside the Controller instead of binding them directly in the XML View.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Could you please enhance the question to elaborate more on why binding i18n directly in XML is not applicable? Is it because of the dynamically calculated &lt;CODE&gt;sTime&lt;/CODE&gt; + &lt;CODE&gt;sDate&lt;/CODE&gt; values? If so, how are they being calculated? Are they from an OData service? It would be good to know why the controller approach is being attempted first (c.f.&amp;nbsp;&lt;A href="https://xyproblem.info/" target="_self"&gt;XY problems&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2026 15:44:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-access-i18n-resource-bundle-in-controller-oninit-model-not-loaded/qaa-p/14486976#M4949002</guid>
      <dc:creator>boghyon</dc:creator>
      <dc:date>2026-09-17T15:44:30Z</dc:date>
    </item>
  </channel>
</rss>

