<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="362723" data-post-id="362723">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="greven" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/greven/120/25004_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  greven
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Not missing anything, that is actually what I do on the app where I have multi-language support. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p>
<p>I extract the language from several places, prioritising the URL query parameter, then session, headers, (etc…) and as last resort the localStorage.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362723" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-is-the-strategy-when-guest-user-changed-their-state-inside-liveview/70475/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-362723" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362723"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="362726" data-post-id="362726">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="greven" data-post="12" data-topic="70475">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/greven/48/25004_2.png" class="avatar"> greven:</div>
<blockquote>
<p>that is actually what I do</p>
</blockquote>
</aside>
<p>Ya, the stuff under the line in my response was supposed to signify the end of the response specifically to you <img src="https://forum.elixirforum.com/images/emoji/apple/sweat_smile.png?v=15" title=":sweat_smile:" class="emoji" alt=":sweat_smile:" loading="lazy" width="20" height="20">  Although really the whole response is an open question.  I’ve found localStorage really annoying for these types of things—as mentioned by Koko, it’s good if it’s client-side only as it’s simple, otherwise you need to do the extra ceremony to ensure a non-janky experience.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362726" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-is-the-strategy-when-guest-user-changed-their-state-inside-liveview/70475/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-362726" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362726"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="362771" data-post-id="362771">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="longnightElixir" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/longnightElixir/120/32051_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  longnightElixir
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="sodapopcan" data-post="11" data-topic="70475">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/48/34668_2.png" class="avatar"> sodapopcan:</div>
<blockquote>
<p>why is this better in this situation than using a controller?</p>
</blockquote>
</aside>
<p>For not to lose (logined ) user’s unsaved input and page position, in my opinion, we should  avoid page reload as possible as we can; ideally, when user changed their prefer GUI language, lead to GUI display content change only.<br>
So I’m also considering through a controller as you said, but instead, we emit the request by a XMLHttpRequest from javascript. But this approach brings in another problem: the session updated thing do not triggle current (user’s staying ) liveview update, I may have to place a handle_event to do that, in every liveview; What do you think about this way ?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362771" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-is-the-strategy-when-guest-user-changed-their-state-inside-liveview/70475/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-362771" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362771"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="362773" data-post-id="362773">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sodapopcan" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sodapopcan/120/34668_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sodapopcan
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It’s of course totally up to you how you want to do it, I mostly added my second for others who might find this thread.</p>
<p>I don’t know your specific application’s needs, but it’s generally advised to keep things as simple as possible.  I certainly understanding thinking of every edge case, but when it comes to changing languages, most people are only going to pick once and be done with it.  I wouldn’t worry about things like form state because who is going to start filling out a form in a language they don’t understand then switch their language half-way through?  Again, I’m speaking generally and don’t know your application’s needs, perhaps this is a real use-case for you.</p>
<aside class="quote no-group" data-username="longnightElixir" data-post="14" data-topic="70475">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/longnightelixir/48/32051_2.png" class="avatar"> longnightElixir:</div>
<blockquote>
<p>So I’m also considering through a controller as you said, but instead, we emit the request by a XMLHttpRequest from javascript.</p>
</blockquote>
</aside>
<p>I’m having trouble finding it but people were talking here recently about a workaround to setting session data over LiveViews.  I’m not sure if it actually works yet or needs an update to the framework first.  The problem is that not being able to set session data over websockets is a limitation of websockets itself.  With what you’re suggesting, you would need to be able to send the LiveView’s PID along with the request so the controller could message it back with the new lang (after storing the language in the session) via <code>handle_info</code> where you could re-fetch the page’s data.  Perhaps you can find the thread or someone else could speak to if this is possible or not, but it seems like a lot of ceremony and localStorage is probably the better option for you (for now, at least).  Or see if you can find that thread.  It was this year I’m pretty sure.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="362773" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/what-is-the-strategy-when-guest-user-changed-their-state-inside-liveview/70475/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-362773" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="362773"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>