On SharePoint Online, what you use instead of localized webparts depends whether you intend to use Modern or Classic pages.
On Classic, what is recommended is using App parts. There are two options for those, SharePoint hosted and provider hosted. If it is provider hosted, then the app part will be running in .NET on another server; you can use resx files there, and the user's language is passed to your aspx among the parameters.
If it is SharePoint-hosted, that is to say all JavaScript, then the way to localize those is with JavaScript resource files, with names like "Resources.en-US.js". Details here:
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/localize-sharepoint-add-ins
You can use the resource tokens from SharePoint's own resx files, but you can't use your own resx files. In your aspx you have it load the correct JavaScript resource file using a line like
<script type="text/javascript" src="../scripts/Resources.<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,language_value%>' EncodeMethod='HtmlEncode' />.js"></script>
The "$Resources:wss,language_value" will take the value en-US, or whatever, at run time because it gets it from SharePoint's wss.resx file. Note: app parts run in a separate site in a different domain on the same server, but it will generally inherit the same language as the host site.
Another alternative on Classic pages is to inject JavaScript on a page or in an existing webpart using jslink and client side rendering (CSR). You can inject your JavaScript file plus jQuery if you want. Then in your code you can use a similar technique to load js resource files but using the variable _spPageContextInfo.currentUICultureName. Please note that using html[lang] in JavaScript and CSS is reliable only if you want to use the language of the site, not the language of the user. It is reliable in Modern pages.
http://blog.icefire.ca/post/how-to-achieve-language-specific-styling-in-modern-pages
The techniques above only work for Classic pages. For Modern pages, you need to use SPFx webparts. This is getting long, so read this guidance
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/localize-web-parts